2017-08-01 93 views
0

我正在使用php標題在網站上工作& html版本的頁腳工作方式類似於charmin,但在php中navbar不返回。Navbar將不會崩潰Bootstrap v4.0.0-alpha.5

這裏是我的代碼頭:

<div class="container"> 
     <div class="row"> 
      <div class="col-sm-3"> 
       <div id="logo" class="float-xs-left"> 
        <a class="navbar-brand" href="xxxxxxx/"><img src="img/logo-white.png" /></a> 
       </div> 
      </div> 
      <!--div class="col-sm-6" --> 
      <div class="float-xs-right"> 
       <!--/div> --> 


    <!--cols:12 --> 
       <!--cols:12 --> 
       <div class="offcanvas"> 
        <div class="navbar yamm col-lg-8 col-md-8 col-sm-6 "> 
         <div class="navbar-header"> 
          <button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".offcanvas.menu"> 
           <i class="fa fa-bars"></i> 
           <div class="line line-1"></div> 
           <div class="line line-2"></div> 
           <div class="line line-3"></div> 
          </button> 
         </div> 
         <!-- outside --> 
         <div class="offcanvas menu right"> 
          <div class="navbar-collapse collapse"> 
           <button data-target=".offcanvas.menu" data-toggle="collapse" class="navbar-toggle" type="button"> 
           </button> 
           <div class="nav navbar-nav"> 
            <div class="list-group"> 
             <!-- li><a href=""><span class="home">&#8962;</span></a></li --> 
             <a href="#"><img class="logo-img" src="img/logo-full.png" class="img-responsive" /></a> 
             <a href="index.php" class="list-group-item ">     INICIO </a> 
             <a href="#p5" class="list-group-item " data-toggle="collapse">     home <b class="fa fa-chevron-down"></b></a> 
             <div class="collapse" id="p5"> 
              <a href="page-1.php" class="list-group-item"> 
          Espresso        </a> 
              <a href="page-2.php" class="list-group-item"> 
          Clásico        </a> 
              <a href="page-3.php" class="list-group-item"> 
          Orgánico       </a> 
              <a href="page-4.php" class="list-group-item"> 
          Descafeinado       </a> 
              <a href="page-5.php" class="list-group-item"> 
          Toscana       </a> 
             </div> 
             <a href="page-10.php" class="list-group-item ">     </a> 
             <a href="page-11.php" class="list-group-item ">     </a> 
             <a href="page-12.php" class="list-group-item ">     </a> 
             <a href="#p6" class="list-group-item " data-toggle="collapse">     <b class="fa fa-chevron-down"></b></a> 
             <div class="collapse" id="p6"> 
              <a href="page-11.php" class="list-group-item"> 
                </a> 
             </div> 
             <a href="#p4" class="list-group-item " data-toggle="collapse">     <b class="fa fa-chevron-down"></b></a> 
             <div class="collapse" id="p4"> 
              <a href="page-13.php" class="list-group-item"> 
          item        </a> 
              <a href="#c1" class="list-group-item" data-toggle="collapse"> 
          another one<b class="fa fa-chevron-down"></b> <span class="cat_url" onclick="location.href='other.php'"><i class="fa fa-mail-forward"></i></span>       </a> 
              <div class="collapse" id="c1"> 
               <a href="page-14.php" class="list-group-item">name</a> 
               <a href="item-1.php" class="list-group-item">name</a> 
               <a href="item-2.php" class="list-group-item">name</a> 
               <a href="item.php" class="list-group-item">name</a> 
               <a href="item.php" class="list-group-item">name</a> 
              </div> 
              <a href="#" class="list-group-item"> 
          other page       </a> 
              <a href="#" class="list-group-item"> 
          other page        </a> 
              <a href="#" class="list-group-item"> 
          other page        </a> 
              <a href="page-15.php" class="list-group-item"> 
          other name       </a> 
              <a href="page.php" class="list-group-item"> 
          name       </a> 
              <a href="page.php" class="list-group-item"> 
          name       </a> 
              <a href="#" class="list-group-item"> 
          name       </a> 
             </div> 
             <a href="#p7" class="list-group-item " data-toggle="collapse">     page title <b class="fa fa-chevron-down"></b></a> 
             <div class="collapse" id="p7"> 
              <a href="page-16.php" class="list-group-item"> 
          Name       </a> 
              <a href="page-17.php" class="list-group-item"> 
          name        </a> 
             </div> 
             <a href="#" class="list-group-item ">     page </a> 
            </div> 
            <br/> 

            </div> 
           </div> 
          </div> 
          <!-- /.navbar-collapse --> 
         </div> 
         <div class="pusher"></div> 
         <!-- end outside --> 
        </div> 
       </div> 
      </div> 
      <!--cols:12 --> 
      <div class="navbar yamm "> 
       <div class="navbar-header hidden-lg-up"> 
        <button type="button" class="navbar-toggler" 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> 
       </div> 
       <div class="navbar-toggleable-md collapse"> 
        <ul class="nav navbar-nav"> 
         <!-- li><a href=""><span class="home">&#8962;</span></a></li --> 
         <li class="nav-item                   "> 
          <a href="contacto.php" >Contáctanos</a> 
         </li> 
         <li class="nav-item                   "> 

         </li> 
        </ul> 
       </div> 
       <!-- /.navbar-collapse --> 
      </div> 
     </div> 
    </div> 
    </div> 

</header> 

在控制檯收到此錯誤:

document.querySelector("#nav-toggle") 
.addEventListener("click", function() { 
this.classList.toggle("active"); 
}); 

有誰知道問題是什麼,如何解決呢?

解決

的問題是在頁腳頁眉和調用同一個文件頁面,所以當函數被調用狀態不返回,因爲重複動作3次

+0

你使用jQuery嗎?我不知道版本4是否與衆不同(我懷疑是否),但是我所使用的所有Bootstrap版本都需要jQuery。 –

+0

是的,我使用jQuery的3.1.1,在html版本運作良好,但在HTML不崩潰。 –

回答

0

最後解決這個問題,有是頁眉,頁腳和索引中的三重腳本句子,在頁眉和頁腳中被刪除,就是這樣。