2016-12-06 104 views
0

Logo Centered Inside Navbar 我嘗試使用bootstrap實現它.. 但我不想摺疊標誌部分,只摺疊其他li。以標籤居中的導航Navbar導航欄

<header role="banner"> 
      <nav id="navbar-primary" class="navbar" role="navigation"> 
       <div class="container-fluid"> 
        <div class="navbar-header"> 
         <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-primary-collapse"> 
          <span class="sr-only">Toggle navigation</span> 
          <span class="icon-bar"></span> 
          <span class="icon-bar"></span> 
          <span class="icon-bar"></span> 
         </button> 
        </div> 
        <div class="collapse navbar-collapse" id="navbar-primary-collapse"> 
         <ul class="nav navbar-nav"> 
          <li><a href="#"><span class="glyphicon glyphicon-home" 
          aria-hidden="true"></span> Home</a></li> 
          <li style="margin-right: 80px"><a href="articles.html"><i class="fa fa-pagelines" aria-hidden="true"></i> 
          Articles</a></li> 
          <li style="margin-left: 80px"><a href="signIn.html"><i class="fa fa-sign-in" aria-hidden="true"></i> 
          Sign in</a></li> 
          <li class="active"><a href="signUp.html"><i class="fa fa-sign-in" aria-hidden="true"></i> 
          Sign up</a></li> 
         </ul> 
        </div> 
        <div style="float:none"> 
         <a href="#"><img src="../image/uoblogo.png" height="60px" width="200px" ></a> 
        </div> 
       </div> 
      </nav> 
     </header> 
+0

可能重複的(HTTP ://stackoverflow.com/questions/23400234/centering-brand-logo-in-bootstrap-3-navbar) – vanburen

回答

0

移動圖像的UL內部和應用垂直對齊每個李將解決您的問題

檢查這個codepen

改變你的標記以下

<header role="banner"> 
    <nav id="navbar-primary" class="navbar" role="navigation"> 
     <ul class="nav navbar-nav"> 
      <li> 
      <a href="#"> 
       <span class="glyphicon glyphicon-home icon" aria-hidden="true"></span> Home</a>   
      </li> 
      <li> 
      <a href="articles.html"><i class="fa fa-pagelines icon" aria-hidden="true"></i>Articles</a> 
      </li> 
      <li> 
      <a href="signIn.html"><i class="icon fa fa-sign-in" aria-hidden="true"></i>Sign in</a> 
      </li> 
      <li class="img"> 
      <a href="#"><img src="https://lh6.googleusercontent.com/-lLR_c-yGAKc/AAAAAAAAAAI/AAAAAAAAGoY/3TnWGhgp4-0/s0-c-k-no-ns/photo.jpg" height="60px" width="200px"></a> 
      </li> 
      <li class="active"> 
      <a href="signUp.html"><i class="icon fa fa-sign-in" aria-hidden="true"></i>Sign up</a> 
      </li> 
     </ul> 

    </nav> 
</header> 

和css以下

ul li a{ 
    line-height:50px!important; 
    vertical-align:bottom; 
} 

希望它有幫助

1

這基本上是answered on SO before。你將需要調整CSS的圖像高度等..,並保持navbar-brand出[在引導3導航欄圍繞品牌標誌]的navbar-collapse

.navbar-brand { 
    position: absolute; 
    width: 100%; 
    left: 0; 
    top: 0; 
    text-align: center; 
    margin: auto; 
} 
.navbar-brand > img { 
    display: initial; 
} 
.navbar-toggle { 
    z-index:3; 
} 

http://www.codeply.com/go/G5uYBjmKkf