Fix dropdown menu z-index issue in IE

User-contributed tutorials, tips and tricks

Fix dropdown menu z-index issue in IE

Postby Ola » Mon Jan 18, 2010 6:04 pm

I struggled a long time before I found a real simple solution to my problem. Then I thought I just might share it here.

Problem:
You have a dropdown menu in the header. In Internet Explorer, the dropdown submenu is hidden underneath the container div.

Solution:
Put this in your CSS.
Code: Select all
/* Fix for IE and it's z-index issue */
#header .inside {
   z-index: 1;
}

Why does it work now?
The default Typolight template generates this structure:
Code: Select all
<div id="header">
   <div class="inside">
      <div id="menu">The menu is placed here...</div>
   </div>
</div>
<div id="container">
   The content...
</div>

Both the header inside and container div have position: relative. If there is multiple position:relative divs in your structure, then IE uses separate z layer contexts for each one, which ignore each other.

Our fix makes the header always on top of the container, thus making the container not hiding the dropdown menu.

More info:
http://verens.com/archives/2005/07/15/ie-z-index-bug/
User avatar
Ola
User
 
Posts: 33
Joined: Sat Aug 15, 2009 4:19 pm
Location: Sweden

Return to User tutorials

Who is online

Users browsing this forum: No registered users