Internet Explorer 7中的z-index问题

| 我在这里有一个测试用例。 我要实现的是,蓝色父元素及其绿色子元素像回形针一样围绕红色元素。如您所见,在所有现代浏览器中,此方法都很好用-但在IE7中,绿色元素保留在背景中。 有没有解决方案,我可以在IE7中实现呢? 编辑:至关重要的是,绿色元素保留为蓝色元素的子元素,因为蓝色元素将被动画化,这也将对绿色元素的宽度和位置产生影响。     
已邀请:
在声明z-index的CSS上添加“ 0”。在大多数情况下都可以使用。 在你的情况下
  #middle-container {
      width: 250px;
      height: 300px;
      background: red;
      left: 100px;
      top: 20px;
      z-index: 2;
      position: relative; /* added row to make z-index work */
      opacity: .9;
  }

  #container-behind {
      width: 220px;
      height: 110px;
      padding-left: 70px;
      background: blue;
      top: 80px;
      left: 320px;
      z-index: 1;
      position: relative; /* added row to make z-index work */
  }
    
这适用于IE7 演示:http://jsfiddle.net/dTJ4d/1 演示2:http://jsfiddle.net/dTJ4d/2
<div id=\"middle-container\">    
    #middle-container
    <div id=\"container-behind\">
        #container-behind
    </div>
    <div id=\"inner-behind\">
        #inner-behind
    </div>
</div>
DIV
{
    padding: 10px;
    color: #FFFFFF;
}
#middle-container
{
    width: 250px;
    height: 300px;
    background: #FF0000;
    left: 100px;
    top: 20px;
}
#container-behind
{
    width: 220px;
    height: 110px;
    padding-left: 70px;
    background: #0000FF;
    top: 80px;
    left: 70px;
    z-index: -1;
    position: absolute;
}
#inner-behind
{
    width: 210px;
    padding-left: 70px;
    background: #80E64D;
    position: relative;
    z-index: 1;
    top: 75px;
    left: 50px;
}
编辑:清理了几行代码     

要回复问题请先登录注册