我正在尝试让两个bootstrap3下拉元素在同一行上运行:
我试过这个:
<div class="btn-group btn-block">
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">first
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 1</a></li>
<li><a href="#">Reason 2</a></li>
<li><a href="#">Reason 3</a></li>
</ul>
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">second
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 5</a></li>
<li><a href="#">Reason 6</a></li>
<li><a href="#">Reason 7</a></li>
</ul>
</div>
不幸的是,这两个下拉列表似乎共享相同的ul
列表(仅第二个)。如何将第一个下拉列表绑定到其ul
列表,将第二个下拉列表绑定到自己的ul
列表?
答案 0 :(得分:6)
您需要将dropdowns
分成两个btn-group
:
<div class="btn-group btn-group-inline">
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">first
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 1</a></li>
<li><a href="#">Reason 2</a></li>
<li><a href="#">Reason 3</a></li>
</ul>
</div>
<div class="btn-group btn-group-inline">
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">second
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 5</a></li>
<li><a href="#">Reason 6</a></li>
<li><a href="#">Reason 7</a></li>
</ul>
</div>
答案 1 :(得分:1)
你需要两个不同的div,如:
<ul class="list-inline">
<li>
<div class="btn-group btn-block">
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">first
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 1</a></li>
<li><a href="#">Reason 2</a></li>
<li><a href="#">Reason 3</a></li>
</ul>
</div>
</li>
<li>
<div class="btn-group btn-block">
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">first
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 1</a></li>
<li><a href="#">Reason 2</a></li>
<li><a href="#">Reason 3</a></li>
</ul>
</div>
</li>
</ul>
&#13;
答案 2 :(得分:0)
在buttons
<div class="dropdown pull-left">
<div class="btn-group btn-block">
<div class="dropdown pull-left"> //added this
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">first
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 1</a></li>
<li><a href="#">Reason 2</a></li>
<li><a href="#">Reason 3</a></li>
</ul>
</div> //added this
<div class="dropdown pull-left"> //added this
<button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">second
<span class="caret"></span>
</button>
<ul class="dropdown-menu btn-block">
<li><a href="#">Reason 5</a></li>
<li><a href="#">Reason 6</a></li>
<li><a href="#">Reason 7</a></li>
</ul>
</div> //added this
</div>