Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase bootstrap dropdown menu width

wondering if anyone has any tips on how to increase the dropdown width?

I have a row containing two columns with a a bit of javascript that slides the dropdown up and down when selected. The problem I am having is that I can't seem to figure how to increase the dropdown width when selected, ideally the dropdown would match the column size. But what is happening is that the dropdown width is only the same size as the text within the dropdown does anyone have a suggestion on how to increase the dropdown width to match the column size?

<div class="row question">         <div class="dropdown">             <div class="col-md-6" data-toggle="dropdown">                 First column                 <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                 </ul>             </div>         </div><!-- end of the dropdown -->         <div class="dropdown">             <div class="col-md-6" data-toggle="dropdown">                 second column                 <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                     <li>Insert your menus here</li>                 </ul>             </div>         </div>     </div><!--end of the row question -->  <script>      // ADD SLIDEDOWN ANIMATION TO DROPDOWN //     $('.dropdown').on('show.bs.dropdown', function(e){         $(this).find('.dropdown-menu').first().stop(true, true).slideDown();     });      // ADD SLIDEUP ANIMATION TO DROPDOWN //     $('.dropdown').on('hide.bs.dropdown', function(e){         $(this).find('.dropdown-menu').first().stop(true, true).slideUp();     }); </script> 
like image 746
ChoclateLove Avatar asked Apr 13 '14 11:04

ChoclateLove


People also ask

How do I make my bootstrap dropdown bigger?

In Bootstrap 4, full width dropdown in Navbar might be possible by adding CSS properties either internally or externally based on conveniences. Focus on class dropdown and dropdown-menu only. Now, make top margin of dropdown-menu as zero pixel and add width to 100%. We can also use CSS properties through inline method.

How Align drop down menu in bootstrap Center?

You need to put the dropdown menu and the toggle button inside a . btn-group . Also, Bootstrap provides the . text-center property to align the contents.

How do I add a caret in dropdown?

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.


2 Answers

Update 2018

You should be able to just set it using CSS like this..

.dropdown-menu {   min-width:???px; } 

This works in both Bootstrap 3 and Bootstrap 4.0.0 (demo).


A no extra CSS option in Bootstrap 4 is using the sizing utils to change the width. For example, here the w-100 (width:100%) class is used for the dropdown menu to fill the width of it's parent....

 <ul class="dropdown-menu w-100">       <li><a class="nav-link" href="#">Choice1</a></li>       <li><a class="nav-link" href="#">Choice2</a></li>       <li><a class="nav-link" href="#">Choice3</a></li>  </ul> 

https://www.codeply.com/go/pAqaPj59N0

like image 198
Zim Avatar answered Sep 19 '22 14:09

Zim


Add the following css class

.dropdown-menu {     width: 300px !important;     height: 400px !important; } 

Of course you can use what matches your need.

like image 28
Chuks Avatar answered Sep 22 '22 14:09

Chuks