IE8中的Z-index断了吗?

13 z-index internet-explorer-8

此代码适用于我尝试过的所有其他浏览器,IE8除外.

IE8似乎忽略了z-index - 弹出窗口变成了pop-under.

它位于正确的位置,只是缩略图下方的渲染.

任何人?

谢谢!

HTML:

<a class="thumbnail" href="#thumb">
    <img src="comic_a3_thumb.jpg" height="300" width="212" border="0"
         style="float:right; margin-top:10px;margin-bottom:10px;"
         alt="description" />
    <span>
        <img src="/images/comic_a3_popup.jpg" />
    </span>
</a>
Run Code Online (Sandbox Code Playgroud)

CSS:

.thumbnail{
    position: relative;
    z-index: 0;
}

.thumbnail:hover{
    background-color: transparent;
    z-index: 50;
}

.thumbnail span{ /*CSS for enlarged image*/
    position: absolute;
    background-color: lightyellow;
    padding: 5px;
    left: 0px;
    border: 1px dashed gray;
    visibility: hidden;
    color: black;
    text-decoration: none;
}

.thumbnail span img{ /*CSS for enlarged image*/
    border-width: 0;
    padding: 2px;
}

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
    visibility: visible;
    top: -140px; /*position where enlarged image should offset horizontally */
    left: -500px;
}
Run Code Online (Sandbox Code Playgroud)

Jor*_*nes 15

简单的答案是添加一个z-index大于.thumbnail:hover值的值到悬停状态span.

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
    visibility: visible;
    top: -140px; /*position where enlarged image should offset horizontally */
    left: -500px;
    z-index: 51;
}
Run Code Online (Sandbox Code Playgroud)


小智 6

将这些行放在页面头部

<!--[if IE]>
    <style>
            #your_faulty_div{
            background-color:#000; /*any color it doesn't matter*/
        filter: alpha(opacity=0);
        }
        </style>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

your_faulty_div是由于IE z-index错误导致行为不正常的div.

工作顺利,我在我的所有项目中使用它,我已经定位元素重叠.