英文:
Flexbox not working not working on my nav bar, trying to align the contents in a row, but this is what I get, Can someone please help me?
问题
我已将 flex 应用于此导航栏,仍然无法将项目在一行中对齐,尝试将 flex-direction 更改为 row 也没有成功。导航栏中的元素仍然以列的形式排列,这不是我想要的。请问有人可以帮助解决吗?
获取的输出如下output。
英文:
I have applied flex to this nav, still not able to align the items in a row, tried changing the flex-direction to row as well. Still the elements in the nav bar come up in a column format, this is not what I want, Can someone please help how to get it resolved?
[enter image description here](https://i.stack.imgur.com/zyewu.jpg)
Getting this outputoutput
答案1
得分: 1
尝试:
nav ul {
display: flex;
}
英文:
instead of:
nav {
display: flex;
}
try:
nav ul {
display: flex;
}
答案2
得分: 0
The "flex" property should be put on the parent element of all the child elements to activate. In your code, it seems you put flex on "nav" which has only one element, "ul," so it doesn't show the output that you wanted.
For displaying the list item in flex, you should put flex on the "ul."
So your code will be -
ul{
display: flex;
}
英文:
The "flex" property should be put on the parent element of all the child elements to activate. In your code, it seems you put flex on nav which has only one element, "ul" so it doesn't show out put that you wanted.
For displaying the list item in flex you should put flex on the "ul"
so your code will be -
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
ul{
display: flex;
}
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论