Bootstrap 3折叠菜单在点击时不会关闭 [英] Bootstrap 3 collapsed menu doesn't close on click
本文介绍了Bootstrap 3折叠菜单在点击时不会关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个或多或少标准的导航从bootstrap 3
I have a more or less standard navigation from bootstrap 3
<body data-spy="scroll" data-target=".navbar-collapse">
<!-- ---------- Navigation ---------- -->
<div class="navbar navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
</button>
<a class="navbar-brand" href="index.html"> <img src="#"></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#one">One</a></li>
<li><a href="#two">Two</a></li>
<li><a href="#three">Three</a></li>
<li><a href="#four">Four</a></li>
</ul>
</div>
</div>
</div>
它在较小的设备上正常折叠。点击菜单按钮展开菜单,但如果我在菜单链接上点击(或触摸了),菜单保持打开。我要做什么,再关闭它?
It collapses normally on smaller devices. Clicking on the menu button expands the menu but if I click (or touch for that matter) on a menu link, the menu stays open. What do I have to do, to close it again?
推荐答案
Bootstrap的默认设置是在单击菜单项时保持菜单打开。您可以通过在要折叠的jQuery元素上调用 .collapse('hide');
手动覆盖此行为。
Bootstrap's default setting is to keep the menu open when you click on a menu item. You can manually override this behaviour by calling .collapse('hide');
on the jQuery element that you want to collapse.
这篇关于Bootstrap 3折叠菜单在点击时不会关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文