2016-02-09 94 views
0
<nav class="navbar navbar-default" role="navigation" id="my-navbar"> 
     <div class="container-fluid"> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-brand-centered"> 
        <span class="sr-only">Toggle navigation</span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
       <div class="navbar-brand-centered navbar-brand "> 
       <a href="#" class="navbar-brand"> 
       <img alt="Brand" src="assets/img/logo.png"> 
       </a></div> 

      </div> 
      <div class="collapse navbar-collapse" id=" navbar-collapse"> 
      <ul class="nav navbar-nav navbar-right"> 
      <li><a href="" class="glyphicon glyphicon-user btn btn-default navbar-btn navbar-right"> MyReservations </a> 
      </li> 
      <li> <a href="" class="glyphicon glyphicon-phone-alt btn btn-info navbar-btn navbar-right"> +919986040064 </a> </li> 
      <li><a href="" class="glyphicon glyphicon-envelope btn btn-warning navbar-btn navbar-right"> [email protected] </a> 
      </li>    
      </ul> 


      </div> 
     </div> 
    </nav> 

我正在使用此導航欄。在調整窗口大小時,切換按鈕會出現,但點擊它時沒有任何反應。是否有任何編碼錯誤。我已經包括bootstrap.min.css和bootstrap.min.js和jquery.js和文件,但仍然不解決問題導航欄無法調整窗口大小

+1

控制檯中是否有錯誤? – janhocevar

+0

在您的控制檯是錯誤?你首先加載jquery的bootstrap js? – keypaul

回答

2

您需要通過它的外觀到數據目標更改爲#navbar-collapse

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse"> 
    <span class="sr-only">Toggle navigation</span> 
    <span class="icon-bar"></span> 
    <span class="icon-bar"></span> 
    <span class="icon-bar"></span> 
</button> 

你是針對不同的元素(#navbar-brand-centered),這是你的標誌所在,而不是你的菜單......

1

<button>data-target必須具有相同的<div class="collapse navbar-collapse"id和另一種方式來解決這個問題,要改變id

<div class="collapse navbar-collapse" id="navbar-brand-centered"> 

它也能工作!

jsfiddle-link

相關問題