2017-07-26 181 views
0

我的用於較小屏幕(手機和平板電腦)的導航下拉按鈕不起作用。我已經包含了JS文件,但它仍然無法正常工作。任何人都可以幫助確定爲什麼這不想連接我的js文件。我的用於小屏幕的引導程序導航下拉菜單不起作用

HTML

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title></title> 
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> 
    <link rel="stylesheet" type="text/css" href="css/bootstrap.mini.css"> 
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
</head> 
<body> 
<!-- Header --> 
    <header> 
     <nav class="navbar navbar-default navbar-fixed"> 
      <div class="container"> 
       <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="index.html">AffAttraction</a> 
       </div> 
       <div class="collapse navbar-collapse" id="myNavbar"> 
       <ul class="nav navbar-nav"> 
        <li><a href="index.html">Home</a></li> 
        <li><a href="advertisers.html">Advertisers</a></li> 
        <li><a href="publishers.html">Publishers</a></li> 
        <li><a href="blog.html">Blog</a></li> 
        <li><a href="about.html">About Us</a></li> 
        <li><a href="contact.html">Contact Us</a></li> 
       </ul> 
       <form class="navbar-form navbar-right"> 
       <input type="email" name="email" class="form-control" placeholder="Email" required=""> 
       <input type="password" name="password" class="form-control" placeholder="Password" required=""> 
       <button type="submit" class="btn btn-green">Login <span class="glyphicon glyphicon-log-in"></span></button> 
       </form> 
       </div> 
      </div> 
     </nav> 
    </header> 
<!-- Header -- > 
<!-- Showcase --> 
    <div id="showcase"> 
     <div class="container"> 
      <div class="row"> 
       <div class="col-sm-12"> 
       <h1><span class="highlight">Performance</span> Based Marketing</h1> 
       <p>Do you have traffic? Let us help you monetize and profit from your websites, apps, games, blogs, and more!</p> 
       </div> 
      </div> 
     </div> 
    </div> 
<!-- Showcase --> 
<script src="js/bootstrap.js"></script> 
<script src="js/bootstrap.mini.js"></script> 
</body> 
</html> 

我已經在我的下CSS鏈接頂部包括,如果你認爲這可能是一個問題。我也試過把它放在body標籤和html標籤下面。我迷失在做什麼。這些文件確實存在!

回答

0

我試着運行你的代碼,用CDN版本替換你的本地引導樣式表。當我加載它時,我因爲缺少jQuery而崩潰。加入jQuery的頭裏面後,它的工作:

<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>

0

如果你想在引導CSSJS文件連接上你的HTML,你可以很容易地做到這一點與引導CDN。

這給你的<head>添加爲引導樣式 https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

這對你的<body>爲引導的JavaScript鏈接 https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js

另外補充JQuery的自舉才能正常工作 https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js

+0

使用CDN是可能是好的,但它也需要更多的時間來抓取文件,以及如果文件不存在(由於某種原因,它們的服務器已關閉),然後您的網站無法正常運作。我會堅持我使用的方式來確保我從不依賴於另一臺服務器。 –

+0

然後確保在Bootstrap腳本的頂部添加JQuery腳本以便工作:) –

相關問題