How to adjust level of a bar with double lists

Asked

Viewed 18 times

0

Hi I created 2 lists inside a navbar, but the list left ta at the top and right at the bottom, I wanted them to be on the same level,

*{
    margin: 0;
    padding: 0;
}

nav.top{
    width: 100%;
   background: crimson;
   padding-bottom: 10px;
   padding-top: 10px;
}
.esquerda{
    text-align: left;
    padding: 0;
}

.direita{
    text-align: right;
    margin-right: 15px;
   
}
nav ul li{
    list-style: none;
    display: inline-block;
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    text-align: center;
    border-right: 1px solid #fff;
    line-height: 1;
    padding-left: 10px;
    padding-right: 10px;
}
nav ul li:nth-child(6){
    border-right: 4px solid transparent;
}
ul.esquerda li:nth-child(2){
    border-right: 4px solid transparent;
}
nav ul li i{
    margin: 0 15px;
}
nav ul li:hover{
    background: #000;
    color: #fff;
}
nav ul li a{
    border-right: 1px solid #fff;
    line-height: 1;
    background: #fff;
    
}

@media (max-width:800px){
    .esquerda{
        display: none;
    }
    .direita{
        display: none;
    }
    nav.top{
        display: none;
    }
}
 
        <nav class="top">
            <ul class="esquerda">
                <li><i class="fa fa-home"></i>About</li>
                <li><i class="fa fa-home"></i>About</li>
            </ul>
            <ul class="direita">
                <li><i class="fa fa-home"></i>About</li>
                <li><i class="fa fa-pencil"></i>Portfolio</li>
                <li><i class="fa fa-envelope"></i>Contact</li>
                
                <li><i class="fa fa-home"></i>About</li>
                <li><i class="fa fa-pencil"></i>Portfolio</li>
                <li><i class="fa fa-envelope"></i>Contact</li>
            </ul>
        </nav>
    </div>
    <h1>TEXTO</h1>

inserir a descrição da imagem aqui

1 answer

0


You can use flex in Nav and use the property justify-content: space-between; to place a UL on one side and the other UL of the other

It won’t be good here, but test in Whole Page you will see how it looks, and then with a @media you treat the responsiveness

* {
  margin: 0;
  padding: 0;
}

nav.top {
  width: 100%;
  background: crimson;
  padding-bottom: 10px;
  padding-top: 10px;

  display: flex;
  justify-content: space-between;
}

.esquerda {
  text-align: left;
  padding: 0;
}

.direita {
  text-align: right;
  margin-right: 15px;

}

nav ul li {
  list-style: none;
  display: inline-block;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  text-align: center;
  border-right: 1px solid #fff;
  line-height: 1;
  padding-left: 10px;
  padding-right: 10px;
}

nav ul li:nth-child(6) {
  border-right: 4px solid transparent;
}

ul.esquerda li:nth-child(2) {
  border-right: 4px solid transparent;
}

nav ul li i {
  margin: 0 15px;
}

nav ul li:hover {
  background: #000;
  color: #fff;
}

nav ul li a {
  border-right: 1px solid #fff;
  line-height: 1;
  background: #fff;

}

@media (max-width:500px) {
  .esquerda {
    display: none;
  }

  .direita {
    display: none;
  }

  nav.top {
    display: none;
  }
}
<nav class="top">
  <ul class="esquerda">
    <li><i class="fa fa-home"></i>About</li>
    <li><i class="fa fa-home"></i>About</li>
  </ul>
  <ul class="direita">
    <li><i class="fa fa-home"></i>About</li>
    <li><i class="fa fa-pencil"></i>Portfolio</li>
    <li><i class="fa fa-envelope"></i>Contact</li>

    <li><i class="fa fa-home"></i>About</li>
    <li><i class="fa fa-pencil"></i>Portfolio</li>
    <li><i class="fa fa-envelope"></i>Contact</li>
  </ul>
</nav>

<h1>TEXTO</h1>

  • Thanks Hugo to starting in flexbox, obg fico otmo here, abraços desde o do grupo CSS Br.

  • @Jslevel this ai study a lot Flex, it helps a lot to build layouts! Tmj

Browser other questions tagged

You are not signed in. Login or sign up in order to post.