The layout I have created utilizes absolute positioning and includes a CSS-based menu in the header section. It functions perfectly in Firefox, however, when viewed in Internet Explorer 7 and 8, the menu dropdowns are hidden by the content area. Unfortunately, IE does not seem to recognize the z-index property in this scenario.
Despite my research on stacking contexts and the z-index bug, I have been unable to resolve the issue. Is there a solution to this problem that does not involve removing the position:absolute
from #content
? I am open to changing the positioning method for the navigation area if necessary.
Below is the simplified version of the code:
<!DOCTYPE html>
<html>
<head>
<style>
#nav {margin:0; padding: 0; position: absolute; left: 0; top: 0; right: 0; height: 2em; background: #eee}
#nav > li {float: left; list-style: none; position: relative; }
#nav > li > a {display: block; position: relative; margin: 0; background-color: #eee; padding: 5px; border: 1px solid #eee; text-decoration: none; color: #444;}
#nav > li:hover > a { background-color: #ddd; }
#nav li ul { z-index: 1; display: none; position: absolute; padding: 0; margin: 0; list-style: none; border: 1px solid black; background: #eee; width: 100px; }
#nav li:hover ul {display: inline;}
#nav li ul li {list-style: none; margin: 0; padding: 0; height: 5em; }
#nav li ul li a {display: block; padding: 5px; margin: 0; color: #444; text-decoration: none; white-space: nowrap;}
#content { position: absolute; top: 3em; left: 0; right: 0; bottom: 0; background: #ccc; }
</style>
</head>
<body>
<ul id="nav">
<li><a href="#">A</a><ul><li>...</li></ul></li>
<li><a href="#">Group B</a><ul><li>...</li></ul></li>
<li><a href="#">The third group</a><ul><li>...</li></ul></li>
</ul>
<div id="content"></div>
</body>
</html>