IE6和IE7父zIndex问题
据我了解。我需要将 div 2 放在 div 3 前面。如何在 IE6 和 IE7 中执行此操作。所有其他浏览器都工作正常。这是我的代码。
CSS
div {
position:absolute;
}
#div1 {
background:#0F9;
top:0;
left:0;
width:500px;
height:400px;
}
#div2 {
background:#C00;
top:20px;
left:280px;
width:100px;
height:100px;
z-index:3;
}
#div3 {
background:#006;
top:10px;
left:10px;
width:300px;
height:200px;
z-index:2;
}
代码
<div id="div1">
<div id="div2"></div>
</div>
<div id="div3"></div>
For my understand. I need to put div 2 in front of div 3. How can I do this in IE6 and IE7. All of others browsers works normal. Here is my code.
CSS
div {
position:absolute;
}
#div1 {
background:#0F9;
top:0;
left:0;
width:500px;
height:400px;
}
#div2 {
background:#C00;
top:20px;
left:280px;
width:100px;
height:100px;
z-index:3;
}
#div3 {
background:#006;
top:10px;
left:10px;
width:300px;
height:200px;
z-index:2;
}
Código
<div id="div1">
<div id="div2"></div>
</div>
<div id="div3"></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在IE6/7/8、Chrome和Firefox中测试了以下内容。这会将
#two
置于#one
和#third
HTML :
CSS:
实际操作中: http://www.webdevout.net/test?02C
I have tested the following in IE6/7/8, Chrome, and Firefox. This puts
#two
in between#one
and#three
HTML :
CSS:
In Action: http://www.webdevout.net/test?02C
请参阅 Internet Explorer z-index 错误?。
您需要为“
#div1
”显式设置z-index
。只需设置#div1 { z-index: 0; }
你的问题就解决了。http://www.webdevout.net/test?01c
See Internet Explorer z-index bug?.
You need to explicitly set the
z-index
for your "#div1
". Simply set#div1 { z-index: 0; }
and your problem is solved.http://www.webdevout.net/test?01c
据我所知,这个问题没有已知的解决方案,因为 #div1 在 IE7 中自动获得“z-index:0”,这可以防止 #div2 与 #div3 重叠。
为了使 FF 和 Chrome 的行为更像 IE7,请向所有未指定“z-index”的元素添加“z-index:0”。这不会解决您的问题,但可能有助于测试。
As far as I know, there is no known solution for this problem, since the #div1 gets automatically a "z-index:0" in IE7, which prevents the #div2 from overlapping #div3.
To make FF and Chrome behave more like IE7, add "z-index:0" to all elements with no "z-index" specified. This will not solve your problem, but might facilitate testing.