简体   繁体   English

topbar CSS问题

[英]Issue with topbar CSS

I am trying to get my code to have two navigation on top of each other This is the code below that I have and my CSS. 我正在尝试让我的代码彼此之间有两个导航。这是下面的代码以及我的CSS。 How do I do a division line after every link on the second nav? 在第二个导航栏上的每个链接之后,如何做分割线? This is what I am trying to archive. 这就是我要存档的内容。

Is there a way to add icons to the navigation? 有没有一种方法可以将图标添加到导航中?

应该是什么

 navbar { display: flex; justify-content: space-between; background-color: black; color: white; height: 40px; } li { display: inline-block; padding: 14px 16px; } nav { display: flex; justify-content: space-between; background-color: #444444; color: white; text-align: center; height: 90px; margin: auto; padding-top: 5px; padding-bottom: 5px; } li { display: inline-block; font-family: Arial, Helvetica, sans-serif; font-size: 14px; padding: 14px 16px; } 
 <navbar> <ul class="title-area"> <!-- float this left --> <li>Sunt</li> <li>Beatae Vita</li> </ul> <p>Doleremquee laudantium otam Doloremque laudantium otam</p> <ul class="nav-items"> <!-- float this right--> <li>Arhieto</li> <li>Aperam</li> <li>Totam</li> <li>Rem</li> </ul> </navbar> <nav> <ul class="title-area"> <!-- float this left --> <li>Sunt</li> <li>Beatae Vita</li> </ul> Doleremquee laudantium otam Doloremque laudantium otam <ul class="nav-items"> <!-- float this right--> <li>Arhieto</li> <li>Aperam</li> <li>Totam</li> <li>Rem</li> </ul> </nav> 

This is my code https://jsfiddle.net/4zpmskro/ 这是我的代码https://jsfiddle.net/4zpmskro/

So in order to make this work with the code you are using I tried to keep your use of ul consistent. 因此,为了使您使用的代码能够正常工作,我尝试使您对ul的使用保持一致。

<nav>
  <ul class="title-area">
    <!-- float this left -->
    <li>Sunt</li>
    <li>Beatae Vita</li>
  </ul>

  <ul>
    <li>Doleremquee laudantium otam Doloremque laudantium otam</li>
  </ul>

  <ul class="nav-items">
    <!-- float this right-->
    <li>Arhieto</li>
    <li>Aperam</li>
    <li>Totam</li>
    <li>Rem</li>
  </ul>
</nav>

Then in your CSS I added this 然后在您的CSS中添加了这个

nav ul {
  border-right: 1px solid red;
  padding: 0;
  margin: 0;
}

nav ul:last-child {
  border-right: 0;
}

This will add a right border to your ul elements and then remove the last one. 这将为您的ul元素添加一个右边框,然后删除最后一个。 I only applied this to the bottom nav but the same set up could be applied to the top navigation bar as well. 我仅将其应用于底部nav但相同的设置也可以应用于顶部导航栏。 Border is red but you can change it to any color. 边框为红色,但您可以将其更改为任何颜色。 Here is an updated version of your js.fiddle Hope that helps. 这是您的js.fiddle Hope的更新版本 ,可以为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM