当平板电脑/移动视图中的菜单崩溃时,我无法启动引导下拉菜单或按钮。这是我的导航html:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#"><img alt="brand" height="50" width="100" src="media/expend-logo.svg"></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
这些是脚本:
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="Scripts/bootstrap.min.js"></script>
<script>
$(document).ready(function () {
$('.dropdown-toggle').dropdown();
});
</script>
我做错了什么?提前谢谢!
答案 0 :(得分:1)
试试这个。希望它有效。
<nav class="navbar navbar-default navbar-fix-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">
<img src="imgs/your image here" width="300" height="300" class="img-responsive">
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-menu" 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>
</div>
<div id="nav-menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="page one">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
Home
</a>
</li>
<li>
<a href="another page">
About
</a>
</li>
<li>
<a href="third link">
Contact us
</a>
</li>
<li>
<div id="nav-options" class="btn-group pull-right hidden-xs">
<button type="button" class="btn btn-default dropdown-toggle thumbnail" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-education" aria-hidden="true"></span>
Academics
</button>
<ul class="dropdown-menu">
<li><a href="link1"><p class="text-center"> Link page</p></a> </li>
<li role="separator" class="divider"></li>
<li><a href="link2"><p class="text-center"> Linkpage 2</p></a></li>
<li role="separator" class="divider"></li>
<li><a href="link3"><p class="text-center"> Link page 3</p></a></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</nav>
并记住这个
答案 1 :(得分:0)
您未正确添加脚本。这对我有用。
POST