Answer the question
In order to leave comments, you need to log in
Grouping dropdown buttons in Twitter bootstrap?
Dear, please recommend the simplest way to achieve grouped button effect for dropdown .
Based on the API, the code should look something like this:
<div class="btn-group">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
January
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#" class="active">January</a></li>
<li><a href="#">February</a></li>
<!-- ... -->
</ul>
</div>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
2012
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#" rel="2012" class="active">2012</a></li>
<li><a href="#" rel="2011">2011</a></li>
<li><a href="#" rel="2010">2010</a></li>
<li><a href="#" rel="2009">2009</a></li>
</ul>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
As a solution, insert content into a grouped button, and tweak the styles a bit.
Finished working example.
jsfiddle.net/RayZ/CgBTn/1/
.btn-group.btn { border: 0; padding: 0; }
.btn-group.btn > .btn { border-radius: 0 }
.btn-group.btn > .dropdown-menu { text-align: left; }
.btn-group.btn:first-child > .btn {
-webkit-border-radius: 4px 0 0 4px;
-moz-border-radius: 4px 0 0 4px;
border-radius: 4px 0 0 4px;
}
.btn-group.btn:last-child > .btn {
-webkit-border-radius: 0 4px 4px 0;
-moz-border-radius: 0 4px 4px 0;
border-radius: 0 4px 4px 0;
}
<div style="padding:20px;">
<div class="btn-group">
<button class="btn btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
One
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">foo</a></li>
</ul>
</button>
<button class="btn btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Two
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">foo</a></li>
</ul>
</button>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question