Bootstrap 3: navbar collapse 折叠但不展开
Bootstrap 3: navbar collapse collapsing but not expanding
我正在使用 Bootstrap 3.
构建一个相当简单的静态网站
在导航方面,我需要桌面上的全宽导航栏和移动设备上的 "hamburger" 菜单。
所以我选择了 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 or 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.
——————
但是,当我在浏览器中调整 window 大小时,导航栏将变成汉堡菜单,但汉堡菜单不可点击且不会展开。
知道这里出了什么问题吗?
您还需要加载 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>
错误是:
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>
现在完美运行了。
我正在使用 Bootstrap 3.
构建一个相当简单的静态网站在导航方面,我需要桌面上的全宽导航栏和移动设备上的 "hamburger" 菜单。
所以我选择了 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 or 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.
——————
但是,当我在浏览器中调整 window 大小时,导航栏将变成汉堡菜单,但汉堡菜单不可点击且不会展开。
知道这里出了什么问题吗?
您还需要加载 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>
错误是:
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>
现在完美运行了。