2017-06-27 136 views
0

我試圖製作一個使用bootsrap的網站,菜單似乎不工作(它不可點擊)。我檢查了bootstrap網站,並且與我所做的代碼和此代碼沒有區別。或者 - 我無法看到它。Bootstrap導航欄不可點擊

<!doctype html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>Untitled Document</title> 
<link rel="stylesheet" type="text/css" href="css/style.css"> 
<link rel="stylesheet" type="text/css" href="css/bootstrap.css"> 

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

</head> 

<body> 
<nav class="navbar navbar-default"> 
<div class="container-fluid"> 

<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="#">ikb</a> 
</div> 

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
    <ul class="nav navbar-nav navbar-right"> 
    <li><a href="#">Link</a></li> 
    <li><a href="#">Link</a></li> 
    <li><a href="#">Link</a></li> 
    <li><a href="#">Link</a></li> 
    <li class="dropdown"> 
     <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> 
     <ul class="dropdown-menu"> 
     <li><a href="#">Action</a></li> 
     <li><a href="#">Another action</a></li> 
     <li><a href="#">Something else here</a></li> 
     <li role="separator" class="divider"></li> 
     <li><a href="#">Separated link</a></li> 
     </ul> 
    </li> 
    </ul> 
</div> 
</div> 
</nav> 
</body> 
</html> 
+0

負荷'jquery.js'。並且記住檢查控制檯是否有任何錯誤是詢問[so]的先決條件,因此重新搜索關於該主題的可能存在的問題/答案也是如此。 –

回答

1

您應該首先加載jQuery而不是bootstrap。比它應該工作。

bootstrap.js需要jQuery才能工作。

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

我認爲jquery.js和bootstrap.js存在於/ js /文件夾中。

+0

你好,我添加了jQuery之後。導航欄不再崩潰。但jQuery使導航欄可點擊。 –

0

用戶此代碼。據之前`bootstrap.js`工作

<!doctype html> 
 
    <html> 
 
    <head> 
 
    <meta charset="utf-8"> 
 
    <title>Untitled Document</title> 
 
    <!-- Latest compiled and minified CSS --> 
 
    
 
    
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 
    
 
    </head> 
 
    
 
    <body> 
 
    <nav class="navbar navbar-default"> 
 
    <div class="container-fluid"> 
 
    
 
    <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="#">ikb</a> 
 
    </div> 
 
    
 
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
     <li><a href="#">Link</a></li> 
 
     <li><a href="#">Link</a></li> 
 
     <li><a href="#">Link</a></li> 
 
     <li><a href="#">Link</a></li> 
 
     <li class="dropdown"> 
 
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> 
 
      <ul class="dropdown-menu"> 
 
      <li><a href="#">Action</a></li> 
 
      <li><a href="#">Another action</a></li> 
 
      <li><a href="#">Something else here</a></li> 
 
      <li role="separator" class="divider"></li> 
 
      <li><a href="#">Separated link</a></li> 
 
      </ul> 
 
     </li> 
 
     </ul> 
 
    </div> 
 
    </div> 
 
    </nav> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
 
    </body> 
 
    </html>