2017-02-10 52 views
0

嗨,當我啓用手機菜單崩潰它停止scrollspy工作。手機菜單崩潰不能用滾動

他們都單獨工作,但沒有在一起,這是自舉的限制?

這是我的導航欄代碼:下面

<body data-spy="scroll" data-target=".navbar" data-offset="80"> 
    <!-- Navigation --> 
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 
    <div class="container"> 
     <!-- Brand and toggle get grouped for better mobile display --> 
     <div class="navbar-header"> 
      <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> 
      <a class="navbar-brand" href="index.html">Davies Builders Stoke Ltd</a> 
     </div> 
     <!-- Collect the nav links, forms, and other content for toggling --> 
     <div class="collapse navbar-collapse"> 
      <ul class="nav navbar-nav navbar-right" id="navigation"> 
       <li> 
        <a data-toggle="collapse" data-target=".navbar-collapse.in" href="#about">About</a> 
       </li> 
       <li> 
        <a data-toggle="collapse" data-target=".navbar-collapse.in" href="#services">Services</a> 
       </li> 
       <li> 
        <a data-toggle="collapse" data-target=".navbar-collapse.in" href="#partners">Partners</a> 
       </li> 
       <li> 
        <a data-toggle="collapse" data-target=".navbar-collapse.in" href="#contact">Contact</a> 
       </li> 

      </ul> 
     </div> 
     <!-- /.navbar-collapse --> 
    </div> 
    <!-- /.container --> 
</nav> 

的DIV有正確的ID,刪除:從每個#navigations a原因data-toggle="collapse" data-target=".navbar-collapse.in" scrollspy做工精細。

回答

0

引導限制無法使用摺疊.navbarscrollspy,下面的代碼可以解決這個問題。

$('.navbar-collapse a').click(function (e) { 
    if (window.innerWidth < 768){ 
     $('.navbar-collapse').collapse('toggle'); 
    } 
    });