Using absolute positioning to hide and show a nested list is one of the better ways to create a dropdown menu, and it can almost be done using only CSS. IE6 needs a little javascript help to respect the :hover pseudo-class. The Sons of Suckerfish will help you there.
Now you have your perfect semantic validating SEO friendly nested list in order to make the drop-down menu the client wants. The CSS is in place and the dummy you’ve thrown up works.
But when you implement it into the site the drop-down partly hides behind the content further down. Offcourse – it has an higher z-index. Easy fix. But then the juggernaut IE comes along and crashes the party.
In all IE, any element that has position:relative and haslayout=true
forms a stacking context. This is not correct, it would need to have a
z-index to act as a stacking context.
Assume you have two stacking contexts:
- B follows A.
- B is higher in the stack, nearest to the user.
A
B
No matter what z-index you choose for it, a child A-x will never leave
its stacking context A.
A. A-1, A-2, A-3 ….
B
No child of A will ever be higher in the stack than B.
A real life example

In my case I had a #header which erroneously formed such a stacking context,
because of
#header {position:relative; width: 920px;} /* haslayout = true */
And there is a regular stacking context following:
#main {position:relative; z-index: 1}
Thus:
#header
#main
No matter what z-index I chose for it, a child (#menu) of #header would never
leave its stacking context #header.
#header #menu
#main
The #menu inside of #header would be painted over by #main. And even if
#main is transparent, the drop down #menu will loose mouse focus and
collapse.
The solution
What it finally came down to was to apply z-index: 2 to #header, to
have the entire #header higher in the stack, nearer to the user, than
#main.

Thank you:
I could have never done this without the help of Ingo Chao and the ever useful css-discuss list.
Tags: css · hover · IE · menu · positioning · z-index5 Comments
5 responses so far ↓
Perfect! Helped heaps! Thanks!
Thanks a lot, I’ve been wrapping my brain around this issue today and finally fixed it after reading your post.
Thank you! I’ve been banging my head against a wall all morning over this issue. I’ve implemented your solution with a jQuery.each loop to decrement an index and apply as the z-index to each of the relevant classes.
Thank you so much! So helpful.
You are a star!! This issue made me pull my hair!!
Great solution!! Thanks a ton!