我遇到的问题是导航栏中的下拉菜单适用于桌面,但不会在移动设备中展开。
以下是实际网站:http://launchsummer.org/
如果您将页面缩小为移动设备大小,您会看到“发布夏季”下拉菜单不会展开。
以下是导航栏的代码:
<!-- Navigation -->
<!-- Note: navbar-default and navbar-inverse are both supported with this theme. -->
<nav class="navbar navbar-inverse navbar-fixed-top navbar-expanded">
<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="[[~1]]">
<img src="assets/logo-nav@2x.png" class="img-responsive" alt="">
</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 class="hidden">
<a href="#page-top"></a>
</li>
<li>
<a href="[[~1]]">Home</a>
</li>
<li>
<a href="[[~3]]">About Us</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Launch Summer <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="[[~4]]"><font color="#080A21">Program Details</font></a></li>
<li><a href="[[~5]]"><font color="#080A21">FAQ</font></a></li>
<li><a href="[[~6]]"><font color="#080A21">Launch Alumni</font></a></li>
<li><a href="[[~2]]"><font color="#080A21">Past Companies</font></a></li>
<li role="separator" class="divider"></li>
<li><a href="https://launch.fluidreview.com/" target="_blank"><font color="#080A21">Apply!</font></a></li>
</ul>
</li>
<li>
<a href="https://www.edx.org/course/becoming-entrepreneur-mitx-launch-x" target="_blank">LaunchX</a>
</li>
<li>
<a href="http://www.mitlaunchclubs.com" target="_blank">Launch Clubs</a>
</li>
<li>
<a href="https://launchsummer.wordpress.com/" target="_blank">Blog</a>
</li>
</ul>
</div>
</div>
<!-- /.navbar-collapse -->
<!-- /.container -->
</nav>
答案 0 :(得分:0)
所以下拉列表已打开但同时关闭beCaUse内部链接有href =“#”删除下拉列表子元素href属性
答案 1 :(得分:0)
在你的vitality.js中,在第23到26行,你有这个功能:
// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
$('.navbar-toggle:visible').click();
});
因此,当我们点击任何项目时,菜单将关闭。您可以执行此操作以防止在单击下拉菜单时关闭菜单。
// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li:not(.dropdown) a').click(function() {
$('.navbar-toggle:visible').click();
});