【发布时间】:2012-08-08 23:42:32
【问题描述】:
我今天一直在努力解决 IE7 z-index 问题,但我无法深入了解它。我下面的代码显示了一个自定义样式的下拉菜单,它位于名为wrapper_bottom_outer 的 div 上方,在除 IE7 之外的所有其他浏览器上,代码都可以在wrapper_bottom_outer 之上显示选择/下拉类。但是,只有在 IE7 上,select/dropdown 才会在wrapper_bottom_outer div 后面显示。
我今天已经read up 讨论了开发人员在 IE7 和 z-indexing 方面遇到的问题,我今天肯定遇到了这些问题。
我有什么明显的遗漏吗?问题归结为堆叠上下文吗?如果是这样,我该如何解决?
<div class="select" style="width: 127px;">
<dl class="dropdown" style="z-index: 2060; width: 127px;">
...content in here...
</dl>
</div>
<div id="wrapper_bottom_outer" style="z-index: 10;">
...content in here...
<div id="wrapper_bottom"></div>
</div>
#wrapper_bottom_outer {
height: 195px;
overflow: visible;
position: relative;
}
.dropdown {
position: relative;
height: 18px;
float: left;
font-size: 11px;
line-height: 12px;
}
.select {
position: relative;
}
$("#wrapper_bottom").mouseenter(function(){
$(".select").css('zIndex', '1000');
$(".dropdown").css('zIndex', '1001');
$("#wrapper_bottom_outer").css('zIndex', '1002');
});
$("#wrapper_bottom").mouseleave(function(){
$(".select").css('zIndex', '2059');
$(".dropdown").css('zIndex', '2060');
$("#wrapper_bottom_outer").css('zIndex', '10');
});
【问题讨论】:
-
当你明确地给下拉类定位时会发生什么 - 即 .dropdown { position: relative; }
-
@McNab 我已经在
.dropdown类上拥有了一个position: relative;。我应该将其添加到原始帖子中,现在已更新。不幸的是,它没有影响。 -
你的父母应该是相对的,但孩子(下拉菜单)应该是“位置:绝对”
-
@bobek 我已将 .select 设置为
relative的位置,并将 .dropdown 设置为absolute的位置,但这对 IE7 上的 z-indexing 没有影响。下拉/选择仍然显示在wrapper_bottom_outer后面。标记非常广泛,因此很难为此将 jsFiddle 放在一起。我现在看不出问题出在哪里。所有在线博客文章、教程和 cmets 都建议将父级的 z-index 设置为高于子级是解决方法。我已经这样做了,但对 IE7 仍然没有影响。
标签: jquery html css internet-explorer-7 z-index