我需要在bootstrap下拉链接中使用多个下拉列表。但是在选择任何选项时,bootstrap下拉列表变为隐藏。我正在使用bootstrap 3框架来完成它。
这是代码`
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" 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="#">Brand</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="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Price</a>
<div class="dropdown-menu price-dropdown" role="menu" style="padding:10px 10px; min-width:280px;">
<div class="form price-form">
<div class="form-group">
<select class="form-control">
<option>Select Options</option>
<option value="">Option A</option>
<option value="">Option B</option>
<option value="">Option C</option>
</select>
</div>
<div class="form-group">
<select class="form-control">
<option>Select Type</option>
<option value="">Type A</option>
<option value="">Type B</option>
<option value="">Type C</option>
</select>
</div>
<div class="form-group">
<select class="form-control">
<option>Select One</option>
<option value="">One</option>
<option value="">Two</option>
</select>
</div>
</div>
</div>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
`
您可以在此处查看 - Demo
答案 0 :(得分:1)
我认为这篇文章将涵盖您的问题,因为它有类似的问题:
Dropdown with a form inside with twitter-bootstrap
以下是您演示的修改版本:
http://jsfiddle.net/t4a6vpqq/1/
唯一的补充是(JS部分):
$('.dropdown-menu.price-dropdown select').click(function (e) {
e.stopPropagation();
});
注意:当您单击选择时,这不会隐藏下拉菜单,但是如果您需要在单击select周围的周围区域时使用它,则需要调整选择器。