[英]Why doesn't my collapsible menu expand when I click on it?
Don't know what I am missing from my code. 不知道我的代码中缺少什么。 When I shrink the size the 3 bars show up but when I click on them they don't toggle the menu.
当我缩小尺寸时,会显示3条,但是当我单击它们时,它们不会切换菜单。
<!DOCTYPE html>
<html>
<head>
<title>Prototype</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data- target="#main-nav">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#" class="navbar-brand">Brand</a>
</div>
<!-- Collect nav links, forms, and other content into div for toggle -->
<div class="collapse navbar-collapse" id="main-nav">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div>
</div>
</nav>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>
here is the code on jsfiddle: http://jsfiddle.net/5SBqQ/ 这是jsfiddle上的代码: http : //jsfiddle.net/5SBqQ/
Bootstrap requires jQuery. Bootstrap需要jQuery。 Adding:
添加:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
before you add bootstrap should fix the issue. 在添加引导程序之前,应先解决此问题。
http://jsfiddle.net/4LWQv/2/ (Removed the script and link tags for jsfiddle) http://jsfiddle.net/4LWQv/2/ (已删除jsfiddle的脚本和链接标签)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.