我有一个Firefox浏览器,但不是IE的弹出菜单的标记。问题在于弹出窗口在其他元素下弹出,并且不受z-index值的影响。下面是一个完整的可运行示例。IE浏览器的CSS定位问题
现在,我知道一个修复不是将div定位为相对的,但我不能这样做,因为在真实代码中,我使用了scriptaculous,并且添加了“position:relative”来执行它需要做什么。此外,我认为这不重要。
是否有另一个修复程序可以使这个代码适用于IE和Firefox?
例子:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>IE Problem</title>
<style type="text/css">
.mydiv{
position: relative;
background: yellow;
border: solid 1px black;
}
table{background:black;}
td.menu{background:lightblue}
table.menu
{
position:absolute;
visibility:hidden;
z-index:999;
}
</style>
<script type="text/javascript">
function showmenu(elmnt){
document.getElementById(elmnt).style.visibility="visible";
}
function hidemenu(elmnt){
document.getElementById(elmnt).style.visibility="hidden";
}
</script>
</head>
<body>
<div class="mydiv" onmouseover="showmenu('one')" onmouseout="hidemenu('one')">
<a href="#">div one</a><br />
<table class="menu" id="one" width="120">
<tr><td class="menu"><a href="#">Item 1</a></td></tr>
<tr><td class="menu"><a href="#">Item 2</a></td></tr>
</table>
</div>
<div class="mydiv" onmouseover="showmenu('two')" onmouseout="hidemenu('two')">
<a href="#">div two</a><br />
<table class="menu" id="two" width="120">
<tr><td class="menu"><a href="#">Item 1</a></td></tr>
<tr><td class="menu"><a href="#">Item 2</a></td></tr>
</table>
</div>
</body>
</html>
这是我一起去的答案。似乎工作,虽然下拉菜单是IE下的一点点闪烁,因为我移动鼠标。 – 2008-11-24 19:54:59