2017-07-24 160 views
1

我新的編程,我決定在引導3.3.6運行一個小測試,但是下拉菜單無法正常工作。我嘗試使用CDN聯繫,以及既爲引導和腳本,但它不是不工作。 我錯過了什麼?下面是代碼:下拉菜單3.3.6不工作

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
    <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="#">Brand</a> 
 
     </div> 
 
    
 
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
 
     <ul class="nav navbar-nav"> 
 
       <li class="active"><a href="#skills">Skills<span class="sr-only">(current)</span></a></li> 
 
       <li class="dropdown"> 
 
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<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> 
 
        <li role="separator" class="divider"></li> 
 
        <li><a href="#">One more separated link</a></li> 
 
        </ul> 
 
       </li> 
 
       <li><a href="#schools">Schools</a></li> 
 
     </ul> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
      <li class="dropdown"> 
 
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Contact Me<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>

有什麼不對這些代碼或我失去了一些東西?

回答

0
  • 您錯過了將CDN文件包含到標題標記中。下面替換頭標記與您的代碼和嘗試。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
 
<html> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <title>Notestrap</title> 
 
    <link href="bootstrap-3.3.6/dist/css/bootstrap.min.css" rel="stylesheet"> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <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"></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="#">Brand</a> 
 
      </div> 
 

 
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
 
       <ul class="nav navbar-nav"> 
 
        <li class="active"><a href="#skills">Skills<span class="sr-only">(current)</span></a></li> 
 
        <li class="dropdown"> 
 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<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> 
 
          <li role="separator" class="divider"></li> 
 
          <li><a href="#">One more separated link</a></li> 
 
         </ul> 
 
        </li> 
 
        <li><a href="#schools">Schools</a></li> 
 
       </ul> 
 
       <ul class="nav navbar-nav navbar-right"> 
 
        <li class="dropdown"> 
 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Contact Me<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/1.11.1/jquery.min.js"></script> 
 
    <script src="bootstrap-3.3.6/dist/js/bootstrap.min.js"></script> 
 

 
</body> 
 

 
</html>