【发布时间】:2015-11-17 15:17:58
【问题描述】:
我正在使用 Bootstrap 3 构建一个相当简单的静态网站。
在导航方面,我需要桌面上的全角导航栏和移动设备上的“汉堡”菜单。
所以我选择了 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 one 或 that one,我确实检查了我是否包含最新的 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.
————
但是,当我在浏览器中调整窗口大小时,导航栏会变成汉堡菜单,但汉堡菜单不可点击且无法展开。
知道这里有什么问题吗?
【问题讨论】:
-
你包含了 jQuery 吗? code.jquery.com/jquery-1.11.3.min.js
-
它有效。检查this
-
@GerritBertier 是的,我有。请参阅我的问题的 UPDATE 部分中的代码。
-
@alirezasafian 有趣。在我的本地机器上,无论是直接在 Chrome 中还是通过quirktools.com/screenfly,它都不起作用。我的其他脚本之一是否有可能与 Bootstrap JS 混淆?
-
检查您的浏览器控制台。
标签: jquery html twitter-bootstrap navbar hamburger-menu