2016-09-25 94 views
-1

我有一個引導頁與導航欄是這樣的:爲什麼導航欄不能伸展到正確的位置?

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 

 
\t <div class="container-fluid sts-screen-fluid"> 
 
\t \t <nav role="navigation" class="navbar-nav navbar-default"> 
 
\t \t \t <div class="container"> 
 
\t \t \t \t <div class="navbar-header"> 
 
\t \t \t \t \t <button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"> 
 
\t \t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t \t <span class="icon-bar"></span> 
 
\t \t \t \t \t </button> 
 
\t \t \t \t \t <span class="navbar-brand">Kn</span> 
 
\t \t \t \t </div> 
 
\t \t \t \t <div class="collapse navbar-collapse"> 
 
\t \t \t \t \t <ul class="nav navbar-nav navbar-right"> 
 
\t \t \t \t \t \t <li><a href=#>Log In</a></li> 
 
\t \t \t \t \t \t <li><a href=#>Sign Up</a></li> 
 
\t \t \t \t \t \t <li><a href=#>Help</a></li> 
 
\t \t \t \t \t </ul> 
 
\t \t \t \t </div> 
 
\t \t \t </div> 
 
\t \t </nav> 
 
\t </div> 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

你看,問題是,我的導航欄似乎並不舒展朝着正確的一路,所以它看起來像這樣:

that navbar is trying to pull a lefty!

我應該怎麼做才能導航欄獲得正確的?

+0

附:我沒有應用任何額外的CSS –

+0

'.sts-screen-fluid'類是否有任何規則? – ferdynator

+0

不,我沒有。 –

回答

0

這是因爲您在container-fluid div中有container div。

+0

我嘗試刪除它,仍然無法使用。 –

0

也許改變container-fluid改爲container

+0

不起作用。你能告訴我一個小提琴或codepen或什麼? –

+0

只需複製其中一個引導示例:http://getbootstrap.com/examples/navbar/ – Flink

0

它似乎工作正常here

<div class="container-fluid sts-screen-fluid"> 
    <nav role="navigation" class="navbar navbar-default"> 
     <div class="container"> 
      <div class="navbar-header"> 
       <button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
       <span class="navbar-brand">Kn</span> 
      </div> 
      <div class="collapse navbar-collapse"> 
       <ul class="nav navbar-nav navbar-right"> 
        <li><a href=#>Log In</a></li> 
        <li><a href=#>Sign Up</a></li> 
        <li><a href=#>Help</a></li> 
       </ul> 
      </div> 
     </div> 
    </nav> 
</div> 
0

你必須使用.navbar類,而不是.navbar-nav<nav>標籤。 .navbar-nav類用於<ul>標記。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 

 
<div class="container-fluid sts-screen-fluid"> 
 
    <nav role="navigation" class="navbar navbar-default"> 
 
     <div class="container"> 
 
      <div class="navbar-header"> 
 
       <button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"> 
 
        <span class="icon-bar"></span> 
 
        <span class="icon-bar"></span> 
 
        <span class="icon-bar"></span> 
 
       </button> 
 
       <span class="navbar-brand">Kn</span> 
 
      </div> 
 
      <div class="collapse navbar-collapse"> 
 
       <ul class="nav navbar-nav navbar-right"> 
 
        <li><a href=#>Log In</a></li> 
 
        <li><a href=#>Sign Up</a></li> 
 
        <li><a href=#>Help</a></li> 
 
       </ul> 
 
      </div> 
 
     </div> 
 
    </nav> 
 
</div> 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

相關問題