Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the width of a dropdown list in Bootstrap 3.0

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.

like image 506
graphmeter Avatar asked Sep 03 '13 11:09

graphmeter


People also ask

How do I increase the width of a dropdown list?

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.

How do I style a dropdown in Bootstrap?

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.

How do I create a big drop down list in HTML?

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.


2 Answers

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.

like image 154
graphmeter Avatar answered Sep 22 '22 14:09

graphmeter


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/

like image 24
Irvin Dominin Avatar answered Sep 22 '22 14:09

Irvin Dominin