代码之家  ›  专栏  ›  技术社区  ›  burhan

CSS:我所有的项目都是一个接一个的,我该如何修复它?

  •  -1
  • burhan  · 技术社区  · 2 年前

    我试着把我所有的东西都放在一行,但我做不到。如何将我所有的东西放在导航栏的一行中?我应该在css代码中添加什么,或者如何解决这个问题。但现在他们都在一起了

    Codepen: https://codepen.io/burhanelaldi/pen/GRPxxRx
    

    我试着创建一个导航栏

    1 回复  |  直到 2 年前
        1
  •  -2
  •   Lee Chase    2 年前

    不完全确定你在问什么,但如果你想让你的流量水平,那么只需添加 display: flex 如下所示。

    ul {
      display: flex;
    }
    

    附言:你不需要在代码笔中添加html、body、head标签等,它应该只是body标签的内容。 附言:你也需要终止标签。

    <!--  I define the <nav> tag in the <body> tag where i want to make the bar -->
    <nav> 
      <ul> <!-- I define the <ul> tag, which is used to show the unordered list. And, then i define the list items in the <li> tag. I define those items which i want to show in the navigation bar. They are gonna go to href -->
        <li><a href="#home">Home</a></li>
        <li><a href="#history">History</a></li>
        <li><a href="#strategies">Strategies</a></li>
        <li><a href="#myGame">My Game</a></li>
        <li><a href="#contact">Contact</a></li>
      </ul>
    </nav>
    <!--  I gave each anchor tag a corresponding div. When we click on the nav bar we are gonna go to those ids -->
    <div id="home">Home</div>
    <div id="history">History</div>
    <div id="strategies">Strategies</div>
    <div id="myGame">My Game</div>
    <div id="contact">Contact</div>