2016-01-15 205 views
3

顯示引導崩導航欄新行

<div class = "collapse navbar-collapse navHeaderCollapse"> 
    <ul class = "nav navbar-nav navbar-right"> 
     <li><a href = "#">Home</a></li> 
     <li><a href = "#">Blog</a></li> 
     <li class = "dropdown"> 
      <a href = "#" class = "dropdown-toggle" data-toggle = "dropdown">Social Media<b class= "caret"></b></a> 
      <ul class = "dropdown-menu"> 
       <li><a href = "#">Twitter</a></li> 
       <li><a href = "#">Facebook</a></li> 
       <li><a href = "#">LinkedIn</a></li> 
      </ul> 
     </li> 
    </ul> 
</div> 

這是結果:

enter image description here

如何放置摺疊導航欄的新行?

編輯: 我想顯示我的導航欄換行,如下圖所示。

enter image description here

+0

我不清楚你想要什麼。請解釋更多 – ehsan88

+0

這是按預期工作 - [jsfiddle](https://jsfiddle.net/auo3t6c5/)。您能否請您發佈完整的'navbar'元素的HTML片段,並解釋您究竟遇到了什麼問題,否則很難說出這裏發生了什麼。 – DavidDomain

+0

@EhsanAbd:你能看到編輯嗎?我是這個社區的新手。 –

回答

2
Try the sample of code for Collapsible Navigation Bar to be appeared in a new row. 

.heading { 
 
    text-align: center; 
 
} 
 
.navbar .navbar-collapse { 
 
    text-align: center; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <title></title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> 
 
    </head> 
 
<body> 
 
    <div class="row"> 
 
    <div class="col-sm-12 heading"> 
 
     <h1>Heading goes here</h1> 
 
    </div> 
 
    </div> 
 
    <div class="row"> 
 
    <nav class="navbar navbar-inverse"> 
 
     <div class="container-fluid"> 
 
     <div class="navbar-header"> 
 
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> 
 
      <span class="icon-bar"></span> 
 
      <span class="icon-bar"></span> 
 
      <span class="icon-bar"></span> 
 
      </button> 
 
     </div> 
 
     <div class="collapse navbar-collapse" id="myNavbar"> 
 
      <ul class="nav navbar-nav"> 
 
      <li class="active"><a href="#">Home</a></li> 
 
      <li class="dropdown"> 
 
       <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1</a></li> 
 
      <li><a href="#">Page 2</a></li> 
 
      <li><a href="#">Page 3</a></li> 
 
      </ul> 
 
     </div> 
 
     </div> 
 
    </nav> 
 
    </div> 
 
</body> 
 
</html>

這裏是sample PEN,希望這對您有所幫助。

0

這裏是工作fiddle我成立

<nav class="navbar navbar-default"> 
    <div class="container-fluid"> 
    <!-- Brand and toggle get grouped for better mobile display --> 
    <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 navbar-right"> 
     <li><a href = "#">Home</a></li> 
     <li><a href = "#">Blog</a></li> 
     <li class = "dropdown"> 
      <a href = "#" class = "dropdown-toggle" data-toggle = "dropdown">Social Media<b class= "caret"></b></a> 
      <ul class = "dropdown-menu"> 
       <li><a href = "#">Twitter</a></li> 
       <li><a href = "#">Facebook</a></li> 
       <li><a href = "#">LinkedIn</a></li> 
      </ul> 
     </li> 
     </ul> 
    </div><!-- /.navbar-collapse --> 
    </div><!-- /.container-fluid --> 
</nav> 

下面是結果:

enter image description here

發生了什麼事是你的類navHeaderCollapse是可能影響你的代碼。

請張貼您當前的CSS類,以便我們看看它。

祝你好運!

+0

我看到了問題。在我的bootstrap css文件中沒有名爲navHeaderCollapse的類。我該怎麼辦? –

+0

如果你沒有它,爲什麼在你的HTML代碼中發佈你的問題?再次,發佈您編寫的CSS代碼(如果有的話),然後右鍵單擊並選擇檢查元素來檢查元素。如果你沒有發佈必要的代碼來回答它,請不要做出負面的回答。 – ldepaula3

+0

我從一個YouTube教程中瞭解到這一點,可能是一個過時的頻道,似乎像引導程序的CSS類已更改(我從http://getbootstrap.com/下載引導程序) –