我正在尝试使用bootstrap创建一个可折叠的导航栏,导航确实会崩溃,但是当我点击它时,它不会下拉,这是我在索引html页面中的所有代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Honk</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="public/stylesheets/styles.css">
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="public/stylesheets/custom.css">
</head>
<body>
<nav class="navbar navbar-fixed-top navbar-inverse">
<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>
<img class="logo" src="public/images/honklogoo.png" alt="">
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a class="discrip" href="#">About</a></li>
<li><a href="#">Commuters</a></li>
<li><a href="#">Travelers</a></li>
<li><a href="#">On Demand</a></li>
<li><a href="#">Safety</a></li>
<li><a href="#">Download</a></li>
</ul>
</div>
</div>
</nav>
</body>
</html>
答案 0 :(得分:3)
你的html中没有bootstrap js脚本(你只有css)
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
它在这里工作:http://jsfiddle.net/swm53ran/26/
btw,请确保将其放在jquery脚本之后,因为bootstrap依赖于jquery