IE7 Absolute element appearing behind relative one

巧了我就是萌 提交于 2019-11-29 11:49:33

In Internet Explorer positioned elements generate a new stacking context, starting with a z-index value of 0. Therefore z-index doesn't work correctly.

See

Bug Report: Explorer z-index bug

and

Squish the Internet Explorer Z-Index Bug

$(function() {
var zIndexNumber = 1000;
$('div').each(function() {
    $(this).css('zIndex', zIndexNumber);
    zIndexNumber -= 10;
});

});

Use the above if already using jQuery. Details here: http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/

I've found a helpful resource to address this:

Long story short, if your absolutely placed element is empty, IE doesn't like to place it in front of other elements (eg. relatively placed text). You can use a 1x1 transparent gif to overcome this, eg. by setting a style like the following on your absolutely placed element.

 .mask {
   background: transparent url('/images/clear.gif') repeat 0 0;
 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!