2016-11-05 191 views
0

有人可以幫我將鏈接集中在我的導航欄上。我一直在嘗試過去的45分鐘。居中導航欄內容

每次我使用display:flex和justify-content:居中它一直工作,直到漢堡包按鈕出現並點擊,然後它全部浮動到左邊。

任何幫助將大規模讚賞。

謝謝

里斯

.navbar { 
 
    background-color: #000; 
 
    justify-content: center; 
 
    height: auto; 
 
    font-family: Gill Sans, Verdana; 
 
    font-size: 15px; 
 
    line-height: 18px; 
 
    text-transform: uppercase; 
 
    letter-spacing: 2px; 
 
    font-weight: bold; 
 
} 
 
nav li:hover { 
 
    background-color: #C00; 
 
    margin: 0; 
 
}
<nav> 
 
    <div class="navbar-container"> 
 
    <!--NAVBAR CONTAINER START --> 
 
    <nav class="navbar navbar-inverse navbar-fixed-top"> 
 
     <div class="navbar-header"> 
 
     <button aria-controls="navbar" aria-expanded="false" class="navbar-toggle" data-target="#navbar" data-toggle="collapse" type="button"> 
 

 
      <span class="icon-bar"></span> 
 
      <span class="icon-bar"></span> 
 
      <span class="icon-bar"></span> 
 
     </button> 
 
     <a class="navbar-brand" href="#"></a> 
 

 
     </div> 
 

 
     <div class="navbar-collapse collapse" id="navbar"> 
 
     <ul class="nav navbar-nav"> 
 
      <li class="active"> 
 
      <a href="#header-container"><strong>HOME</strong></a> 
 
      </li> 
 

 

 
      <li> 
 
      <a href="#meettheband-container"><strong>MEET THE BAND</strong></a> 
 
      </li> 
 

 

 
      <li> 
 
      <a href="#photo-container"><strong>PHOTOS</strong></a> 
 
      </li> 
 

 

 
      <li> 
 
      <a href="#video-container"><strong>VIDEOS</strong></a> 
 
      </li> 
 

 

 
      <li> 
 
      <a href="#getintouch-container"><strong>GET IN TOUCH</strong></a> 
 
      </li> 
 
     </ul> 
 
     </div> 
 

 
    </div> 
 
    <!-- NAVBAR CONTAINER END --> 
 
    </nav>

+0

你的意思'center',你可以給一個草圖或任何更多的細節。 – mmativ

+0

我想沒有添加按鈕...什麼是漢堡按鈕 – Geeky

回答

0
.navbar { 
    background-color: #000; 

    height: auto; 
    font-family: Gill Sans, Verdana; 
    font-size: 15px; 
    line-height: 18px; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    font-weight: bold; 
    text-align:center; 
} 

.navbar .navbar-header { 
    display:table; 
    width:auto; 
    margin:auto; 
} 

nav li:hover { 
    background-color: #C00; 
    margin: 0; 
}