I'm trying to make a bootstrap 3 dropdown button accept the full width (.btn-block class) properties. It doesn't seem to work the same way with the drop down button as it does with regular buttons. Here is my current code:
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-6">
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-primary btn-block dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"></span> Dealer Tools <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Dealer Area</a></li>
<li class="divider"></li>
<li><a href="#"><span class="glyphicon glyphicon-phone"></span> App Registration</a></li>
</ul>
</div>
<!-- Single button -->
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<a href="http://www.agrigro.com/testarea/contact-us/">
<button type="button" class="btn btn-primary btn-block">
<span class="glyphicon glyphicon-envelope"></span> CONTACT US
</button>
</a>
</div>
</div>
How can I get this to work right so the dropdown button takes up the full col-6?
When using a drop down, apply btn-block to btn-group first, then you can add col-?-? in the button's class to control the width of the button sections. Handy little trick.
<!-- Split button -->
<div class="btn-group btn-block">
<button type="button" class="btn col-lg-10 btn-lg btn-danger">Action</button>
<button type="button" class="btn col-lg-2 btn-lg btn-danger dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu col-lg-12" role="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>
Apply btn-block
to both the btn-group
and btn
<div class="btn-group btn-block">
<button type="button" class="btn btn-block btn-primary dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> Dealer Tools <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Dealer Area</a></li>
<li class="divider"></li>
<li><a href="#"><span class="glyphicon glyphicon-phone"></span> App Registration</a></li>
</ul>
</div>
Demo: http://bootply.com/101166
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With