Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

z-index issue with twitter bootstrap dropdown menu

I'm using twitter bootstrap dropdown menu in a fixed navbar at the top of my page.

It all works fine but am having issues with the drop down menu items showing behind other page elements rather than in front of them.

If I have anything on the page with position: relative (like jquery ui accordion, or a google chart) then the drop down menu shows behind it. Tried changing the z-index of the dd menu and of the nav-bar, but doesn't make any difference.

The only way I can get the menu to sit above the other content is to change the content to position: fixed; OR z-index: -1; -but both of these solutions cause other problems.

Appreciate any help you can give me.

I think this is probably some standard issue with CSS positioning that I've misunderstood, so haven't posted any code, but can do if needed.

Thanks.

like image 408
Leon Avatar asked Dec 17 '12 14:12

Leon


People also ask

Why is my Bootstrap drop down not working?

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.

What is the z-index of Bootstrap modal?

just to notice, Bootstrap default . modal is z-index:1050 , so I can't understand why it's not on top of all other context.

How do I add a drop down menu in Bootstrap?

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 align a drop down button to the right?

Use the w3-right class to float the dropdown to the right, and use CSS to position the dropdown content (right:0 will make the dropdown menu go from right to left).


2 Answers

Just realized what's going on.

I had the navbar inside a header which was position: fixed;

Changed the z-index on the header and it's working now - guess I didn't look high enough up the containers to set the z-index initially !#@!?

Thanks.

like image 198
Leon Avatar answered Sep 22 '22 08:09

Leon


IE 7 on windows8 with bootstrap 3.0.0.

.navbar {   position: static; } .navbar .nav > li {   z-index: 1001; } 

fixed

like image 24
Primož Klemenšek Avatar answered Sep 20 '22 08:09

Primož Klemenšek