How can I set the width of a dropdown triggering button in bootstrap 3.0 to be equal to the width of the dropdown list? Similar to what is achieved when using bootstrap-select (http://silviomoreto.github.io/bootstrap-select/). I have tried to wrap the whole list in a div with a col-* class, but that doesn't seem to work:
<div class="row"> <div class="col-xs-4 col-md-4"> <div class="dropdown"> <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">Button</button> <ul class="dropdown-menu" role="menu"> <li><a href="#">Action</a></li> <li><a href="#">Action</a></li> <li><a href="#">Action</a></li> </ul> </div> </div>
Thus, I would like: button width = dropdown menu list = col-* width.
Create a css and set the value style="width:50px;" in css code. Call the class of CSS in the drop down list. Then it will work.
Basic Dropdown To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.
Use a container element (like <div class="dropdown-content">) to create the dropdown menu and add a grid (columns) and add dropdown links inside the grid. Wrap a <div class="dropdown"> element around the button and the container element (<div class="dropdown-content"> to position the dropdown menu correctly with CSS.
I found the solution by setting the dropdown-menu and button width=100%.
.dropdown-menu { width: 100%; } .btn{ width: 100%; }
Now both the button and dropdown list have the same width, controlled by the column width.
If I understand correctly you want to style the menu width according to the larger option you have to override the min-width
property of the .dropdown-menu
list like:
.dropdown-menu { min-width: 0px !important; }
Demo: http://jsfiddle.net/faxyz/4/
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