Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a Bootstrap dropdown submenu to 'dropup'

I have a Bootstrap dropdown menu. The last li item is a submenu. How do I get the submenu to dropup while the full menu drops down? Here's the code:

<div class="dropdown">     <a class="inputBarA dropdown-toggle" data-toggle="dropdown" href="#">FILTER</a>     <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">         <li role="presentation">             <a role="menuitem" href="#">Text</a>         </li>         <li role="presentation">             <label>Label name</label>             <label>Label name</label>             <label class="checkbox">                 <input type="checkbox">                 Text </label>             <label class="checkbox">                 <input type="checkbox">                 Text </label>             <label class="checkbox">                 <input type="checkbox">                 Text </label>             <label class="checkbox">                 <input type="checkbox">                 Text </label>         </li>         <li class="dropdown-submenu">             <a tabindex="-1" href="#">Centralities</a>             <ul class="dropdown-menu">                 <label class="radio">                     <input type="radio" name="options" id="optionsRadios1" value="A" checked>                     AA </label>                 <label class="radio">                     <input type="radio" name="options" id="optionsRadios2" value="B">                     BB </label><label class="radio">                     <input type="radio" name="options" id="optionsRadios2" value="C">                     CC </label><label class="radio">                     <input type="radio" name="options" id="optionsRadios2" value="D">                     DD </label><label class="radio">                     <input type="radio" name="options" id="optionsRadios2" value="E">                     EE </label>             </ul>         </li>     </ul> </div> 
like image 705
user1114864 Avatar asked Jul 10 '13 21:07

user1114864


People also ask

How can change dropdown from click to hover in Bootstrap?

Answer: Use the jQuery hover() method By default, to open or display the dropdown menu in Bootstrap you have to click on the trigger element. However, if you want to show the dropdown on mouseover instead of click you can do it with little customization using the CSS and jQuery.

How do I change the position of a drop down menu in Bootstrap?

Use data-offset or data-reference to change the location of the dropdown.

Why is my dropdown menu not working Bootstrap?

Solution : The dropdown should be toggled via data attributes or using javascript. In the above program, we have forgotten to add a data attribute so the dropdown is not working. So add data-bs-toggle="dropdown" to toggle the dropdown.

How do I make Bootstrap dropdown stay open?

Just wrap the contents of the menu in a form tag. That's it. So, instead of ul. dropdown-menu , use form.


1 Answers

The best solution:

<div class="dropup">    <ul class="dropdown-menu"></ul> </div> 

It's a native class in bootstrap. The bootstrap (using 3.1.1) css file has a .dropup .dropdown-menu selector so that's how I found out.

like image 167
Sem Avatar answered Oct 01 '22 13:10

Sem