2016-11-03 270 views
0

我正在學習使我的導航欄可摺疊。摺疊按鈕圖標可見,但下拉不起作用。任何人都可以找到錯誤在此代碼引導程序崩潰導航欄不起作用

<!Doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>PhotoBomb</title> 
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.css" /> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> 
    <link rel="stylesheet" href="css/style.css"/> 

</head> 
<body> 
    <header> 
     <nav class="navbar navbar-inverse navbar-fixed-top"> 
      <div class="container-fluid"> 
       <div class="navbar-header"> 
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
         <span class="icon-bar"></span> 
        </button> 
        <a class="navbar-brand" href="#"><img src="images/img1.png" width="60px"/>PhotoBomb</a> 
       </div> 
       <div id="myNavbar" class="collapse navbar-collapse"> 
        <ul class="nav navbar-nav"> 
         <li><a href="#"><i class="fa fa-home"></i>Home </a></li> 
         <li><a href="#">About us </a></li> 
        </ul> 
       </div> 
      </div> 
     </nav> 
    </header> 

    <div class="jumbotron text-center"> 
     <h1>Welcome to PhotoBomb</h1> 
     <p>Enhance your memories with the best quality possible</p> 
    </div> 

</body> 

</html> 

回答

1

看來你忘了添加js文件,

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

這裏的工作示例,這應有助於:

<!Doctype html> 
 
<html lang="en"> 
 
<head> 
 
    <meta charset="utf-8"> 
 
    <title>PhotoBomb</title> 
 
    <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.css" /> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> 
 
    <link rel="stylesheet" href="css/style.css"/> 
 

 
</head> 
 
<body> 
 
    <header> 
 
     <nav class="navbar navbar-inverse navbar-fixed-top"> 
 
      <div class="container-fluid"> 
 
       <div class="navbar-header"> 
 
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> 
 
         <span class="icon-bar"></span> 
 
         <span class="icon-bar"></span> 
 
         <span class="icon-bar"></span> 
 
        </button> 
 
        <a class="navbar-brand" href="#"><img src="images/img1.png" width="60px"/>PhotoBomb</a> 
 
       </div> 
 
       <div id="myNavbar" class="collapse navbar-collapse"> 
 
        <ul class="nav navbar-nav"> 
 
         <li><a href="#"><i class="fa fa-home"></i>Home </a></li> 
 
         <li><a href="#">About us </a></li> 
 
        </ul> 
 
       </div> 
 
      </div> 
 
     </nav> 
 
    </header> 
 

 
    <div class="jumbotron text-center"> 
 
     <h1>Welcome to PhotoBomb</h1> 
 
     <p>Enhance your memories with the best quality possible</p> 
 
    </div> 
 

 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/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>