Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navbar split button dropdown with Bootstrap 3

I'd like to make a split button dropdown with Bootstrap 3. I didn't find any working snippet.

My navbar looks like:

<header class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Brand</a>
        </div>
        <div class="navbar-collapse collapse">

            <ul class="nav navbar-nav">
                <li>
                    <a href="#">Example</a>
                </li>
                <li>
                    <a href="#">Example</a>
                </li>
            </ul>

            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                    </ul>
                </li>
            </ul>
        </div><!--/.navbar-collapse -->
    </div>
</header>
like image 831
Syl Avatar asked Dec 12 '13 09:12

Syl


1 Answers

You can place it inside the nav li and add navbar-btn to the btn-group..

            <li>
                  <div class="btn-group navbar-btn">
                    <button class="btn btn-danger">Action</button>
                    <button data-toggle="dropdown" class="btn btn-danger dropdown-toggle"><span class="caret"></span></button>
                    <ul class="dropdown-menu">
                      <li><a href="#">Action</a></li>
                      <li><a href="#">Another action</a></li>
                      <li><a href="#">Something else here</a></li>
                      <li class="divider"></li>
                      <li><a href="#">Separated link</a></li>
                    </ul>
                  </div>
            </li>

Demo: http://bootply.com/100070

like image 178
Zim Avatar answered Nov 07 '22 09:11

Zim