我在bootstrap navbar中有单个链接(eq.news,about)以及一些下拉菜单(Music - > Bands,Releases等)。
当您在移动版本上查看页面时,当您按下任何链接时,bootstrap将关闭其主下拉菜单,当您按下eq时,这是正常的。新闻或关于,但是当您想要访问某些子下拉列表时,这并不好。
我知道有
// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
$('.navbar-toggle:visible').click();
});
阻止按下任何链接时Bootstrap的主下拉菜单关闭,但有没有办法:
按下eq时关闭。新闻或关于
按下eq时保持打开状态。音乐
按下音乐下拉菜单中的链接时关闭。乐队,发行
以下是导航栏代码:
<!-- Navigation -->
<nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
<i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top">
<!-- <i class="fa fa-music"></i> -->PAGE TITLE
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-left navbar-main-collapse">
<ul class="nav navbar-nav">
<!-- Hidden li included to remove active class from about link when scrolled up past about section -->
<li class="hidden">
<a href="#page-top"></a>
</li>
<li>
<a class="page-scroll" href="#news">News</a>
</li>
<li>
<a class="page-scroll" href="#about">About</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Music<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Bands</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Releases</a></li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>