A
A
Andrey Rumm2012-12-07 17:14:04
css
Andrey Rumm, 2012-12-07 17:14:04

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>

It doesn't look quite like it's supposed to.
6jx3C.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Rumm, 2012-12-07
@RayZ

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>

S
sl_bug, 2012-12-07
@sl_bug

jsfiddle.net/GKuhF/280/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question