2016-03-05 18 views
0

我試圖首次使用Twitter Bootstrap(第一次使用前端),但是我已經有問題了。一個是navbar總是顯示在其他組件上。Bootstrap將組件nav放在其他位置

<body> 
     <nav class="navbar navbar-default navbar-fixed-top"> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> 
       <span class="sr-only">Toggle navigation</span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
       </button> 
       <a class="navbar-brand" href="#">Brand</a> 
      </div> 

      <!-- Collect the nav links, forms, and other content for toggling --> 
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
       <ul class="nav navbar-nav"> 
       <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> 
       <li><a href="#">Link</a></li> 
       </ul> 
      </div><!-- /.navbar-collapse --> 
     </nav> 

     <div class="container theme-showcase" role="main"> 
      <div class="alert alert-warning" role="alert"> 
      <strong>Warning!</strong> Best check yo self, you're not looking too good. 
      </div> 
     </div> 



    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
    <!-- Include all compiled plugins (below), or include individual files as needed --> 
    <script src="js/bootstrap.min.js"></script> 
    </body> 

在這種情況下,例如div.container .theme-showcase正在和我永遠無法看到它。

我錯過了什麼?謝謝。

enter image description here

編輯:除去固定頂是不是一個解決方案,我需要的資產淨值總是存在

回答

0

.navbar-fixed-top將給導航欄position: fixed從流中去除它,以便其他元件將開始頁面的頂部。如果你想要一個粘性導航,添加頂部填充到.container.theme-showcase或者如果你想讓導航欄保持靜態,那麼只需刪除.navbar-fixed-top類。

+0

我該如何添加頂部填充? – Mitro

+1

@AlessioMTX嵌入或分離樣式表。做一些研究http://htmldog.com/guides/css/;) – digout

0

由於.navbar-fixed-topposition: fixed,所述nav元件將在底層div的頂部鋪設。請務必將.container .theme-showcase的一些padding-top顯示在導航欄下方。

+0

我應該在哪裏添加填充? – Mitro

+1

在您的CSS中,搜索'.container'或'.theme-showcase'並添加以下內容: '.theme-showcase {padding-top:100px;/*導航欄的高度*/ }' – Roy

相關問題