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?

huangapple go评论67阅读模式
英文:

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 -->

huangapple
  • 本文由 发表于 2023年4月20日 04:01:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76058402.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定