ie下弹出层被其他层遮盖的原因和解决办法

ie下弹出层被其他层遮盖的原因和解决办法  

2012-09-07 14:35:53|  分类: 前端|举报|字号 订阅

 
 
以前好像说过这个问题,今天又遇到了,那就老生常谈,再说一次,说多了不伤身体,反而增加记忆。

现象:

一个设置了position:absolute;z-index:2000;的浮动层,居然被一个设置了position:relative;z-index:1;或者说根本就没有设置浮动属性和z-index的普通层遮住了,这在FF和IE8下是不会发生的,操蛋的IE7和IE6里,他偏偏就发生了,查阅了一点国外的资料,大意就是在ie67下,限定元素和浮动元素都要设置position属性和z-index属性,结合我这优秀的大脑,立马就想到了,只给absolute层设置了z-index,而没有给relative限定层设置z-index,设置后,弹出层如愿以偿的出现了。

举例:

HTML

<div class="rela">

<ul class="posi">

<li>他奶奶的</li>

</ul>

</div>

<div class="wahaha">娃哈哈哈</div>

CSS

.rela{

position:relative;

width:1000px;

height:30px;

z-index:1;/*这个不设置,下面的弹出层posi就会被wahaha给盖住*/

}

.posi

{

position:absolute;

z-index:2000;

width:200px;

height:30px;

top:35px;

left:0;

}

.wahaha{height:300px;background:#333;}



引用的资料原文
CSS: Z-Index and Internet Explorer

If you try to use Z-index with Internet Explorer (I hear this is a problem on both 6 and 7), you may have problems getting it to “listen” when Firefox seems to handle z-index just fine.

The problem is a bug in IE which does not render z-index properly all of the time. If you just use z-index: XXX and do not have a position tag, then it does not work. By adding “position: relative” or “position: absolute” tag to your CSS div tag, it magically works!

Thanks for wasting several hours of mine IE.

See here and here for others with this problem!

出处:http://blog.163.com/zhengyong_04@126/blog/static/16428825920128723553807/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值