IE6和IE7父zIndex问题

发布于 2024-09-06 18:57:06 字数 713 浏览 3 评论 0原文

据我了解。我需要将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

卸妝后依然美 2024-09-13 18:57:07

我在IE6/7/8、Chrome和Firefox中测试了以下内容。这会将 #two 置于 #one#third

HTML :

<html lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <div id="content">
       <div id="one">One</div>
       <div id="two">Two</div>
       <div id="three">Three</div>
    </div>
  </body>
 </html>

CSS:

 #one{
     background-color: #f1f1f1;
     position: absolute;
     left:105px;
     top:155px;
     z-index: 0;
 }
 #two{
     background-color: #c9c9c9;
     position: absolute;
     left:100px;
     top:145px;
     z-index: 1;
 }
 #three{
       background-color: #888888;
       color: #f1f1f1;
       position: absolute;
       left:95px;
       top:135px;
       z-index: 2;
 }

实际操作中: 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 :

<html lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <div id="content">
       <div id="one">One</div>
       <div id="two">Two</div>
       <div id="three">Three</div>
    </div>
  </body>
 </html>

CSS:

 #one{
     background-color: #f1f1f1;
     position: absolute;
     left:105px;
     top:155px;
     z-index: 0;
 }
 #two{
     background-color: #c9c9c9;
     position: absolute;
     left:100px;
     top:145px;
     z-index: 1;
 }
 #three{
       background-color: #888888;
       color: #f1f1f1;
       position: absolute;
       left:95px;
       top:135px;
       z-index: 2;
 }

In Action: http://www.webdevout.net/test?02C

岁月静好 2024-09-13 18:57:07

请参阅 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

第七度阳光i 2024-09-13 18:57:07

据我所知,这个问题没有已知的解决方案,因为 #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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文