我有一个使用Boostrap 3.2的页面。当我重新调整窗口大小(chrome)以触发响应式设计时,导航栏的行为非常奇怪。它可以工作一次,但任何后续调用根本不起作用。
奇怪的是,我无法在jsFiddle中表现出同样的行为。所以,我将介绍保管箱链接
https://dl.dropboxusercontent.com/u/3740186/test/publications.html
导航栏的HTML
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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_big.png" width="30" height="30" title="PIT" alt="PIT" />
Test Pitt
</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">
<li>
<a href="./publications.html">Home</a>
</li>
<li>
<a href="./publications.html">Members</a>
</li>
<li>
<a href="./publications.html">Research</a>
</li>
<li>
<a href="./publications.html">Publications</a>
</li>
<li class="active">
<a href="./publications.html">Teaching</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
由于
答案 0 :(得分:2)
最后你的脚本出了问题。
$('.collapse').on('shown.bs.collapse', function (e) {
$("#" + e.target.id.replace("abs_", "btn_")).html("<span class=\"glyphicon glyphicon-collapse-up\" aria-hidden=\"true\"></span> Hide Abstract");
});
$('.collapse').on('hidden.bs.collapse', function (e) {
$("#" + e.target.id.replace("abs_", "btn_")).html("<span class=\"glyphicon glyphicon-collapse-down\"aria-hidden=\"true\"></span> Show Abstract");
});
您可以将这些事件添加到所有.collapse
元素,其中包括重新调整窗口大小时的菜单。