Bootstrap 3:导航栏折叠折叠但不扩展

时间:2015-11-17 15:17:59

标签: jquery html twitter-bootstrap navbar hamburger-menu

我正在使用Bootstrap 3构建一个相当简单的静态网站。

在导航方面,我需要一个桌面全宽导航栏和一个汉堡包#34;手机上的菜单。

所以我选择了Bootstrap的导航栏崩溃:

<nav class="navbar navbar-default">
  <div class="container">
    <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="index.html"><img src="images/logo.png" alt="" /></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 navbar-right press">
              <li><a href="about.html">About</a></li>
              <li><a href="faq.html">FAQ</a></li>
              <li><a href="http://www.domain.com/blog/">Blog</a></li>
              <li><a href="index-FR.html"><img src="images/FR-flag-icon.png" alt="French Version" /></a></li>
              <li><a href="index.html"><img src="images/US-flag-icon.png" alt="English Version" /></a></li>
          </ul>
      </div>
    </div>
</nav>

正如许多其他类似问题(如this onethat one)所示,我DID检查我是否包含最新的Bootstrap JS文件,我的<head></head>标记之间有以下行:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>

- - - -

更新:我的<head></head>中也有以下内容:

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
        <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
        <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all">
        <!-- web-font -->
        <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,100,200,300,500,600,' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/animate.css">
        <link rel="stylesheet" href="css/jquery.wordrotator.css">       
        <!-- web-font -->
        <!-- js -->
        <script src="js/jquery.min.js"></script>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="keywords" content="email, productivity app, iphone app, clarity, peace" />

另外,在上面的代码下面,我也有一些自定义的JS脚本。

- - - -

更新2 :这是我的浏览器控制台日志:

http://localhost:8888/timyo/js/move-top.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/timyo/js/easing.js Failed to load resource: the server responded with a status of 404 (Not Found)
bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher
http://localhost:8888/timyo/images/themes.png Failed to load resource: the server responded with a status of 404 (Not Found)
base.js:1624 SVG's SMIL animations (<animate>, <set>, etc.) are deprecated and will be removed. Please use CSS animations or Web animations instead.

- - - -

但是,当我在浏览器中并调整窗口大小时,导航栏将变为汉堡菜单,但汉堡菜单不可点击且不会扩展。

知道这里有什么问题吗?

2 个答案:

答案 0 :(得分:0)

错误是:

bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher

我只是用以下内容更新了我的部分:

<script src="http://code.jquery.com/jquery-2.1.4.js"></script>

现在它完美无缺。

答案 1 :(得分:-1)

您还需要加载Bootstrap CSS主题,缩小或完整:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>

参考此处的入门:http://getbootstrap.com/getting-started/