2017-06-19 89 views
0

我在努力理解爲什麼我的響應式導航欄摺疊按鈕無法展開。在這種情況下,我的網頁是搜索結果頁面。Boostrap當搜索結果爲空時無法展開導航欄

http://uforest.org/search.php?user_query=test

當搜索結果爲空(上圖),導航欄崩潰不會打開。

http://uforest.org/search.php?user_query=mango

然而,當搜索結果得到的至少一個結果,例如上面的網址,導航欄摺疊按鈕可以擴展。

有誰知道這是爲什麼?

在我的navbar代碼下面,我沒有爲所有其他頁面使用問題。

<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="#bs-example-navbar-collapse-1"> 
        <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.php">Urban Forest</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"> 
        <li> 
         <a href="about.php">About</a> 
        </li> 
        <li> 
         <a href="recent_post.php">Plant Index</a> 
        </li> 
        <li> 
         <a href="http://uforest.blogspot.com" target="_blank">Blog</a> 
        </li> 
       </ul> 
      </div> 
      <!-- /.navbar-collapse --> 
     </div> 
     <!-- /.container --> 
    </nav> 

回答

1

我檢查了你的兩個鏈接。

"http://uforest.org/search.php?user_query=test"你不包括bootstrap.min.js

您可以檢查它在這裏:查看源代碼:http://uforest.org/search.php?user_query=test

實際上,你缺少下列文件

<!-- jQuery --> 

<script src="/js/jquery.js"></script> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 

<!-- Bootstrap Core JavaScript --> 
<script src="/js/bootstrap.min.js"></script> 

它們已經在view-source:http://uforest.org/search.php?user_query=mango

只是包括它,它會工作。

玩得開心

+0

哦......謝謝,我將它們轉移到頭標籤,現在它工作正常。這很奇怪,但他們兩人實際上屬於同一頁面。而那些js腳本標籤放在身體結束標記之前,並且位於我的php標籤之外用於搜索結果。你知道爲什麼他們會在沒有結果的情況下消失嗎? – Jake

+0

對不起,我不知道。 –

+0

至少你找到了原因,非常感謝! – Jake