[][1]

通常设置position后,通过z-index属性来设置div的层叠情况。

但是在IE7中,设置position后,z-index会失效。导致div的层叠出现问题。

具体效果可以看这个页面

http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html

以下分别是IE7与IE8之间的差别:


请先认真看他们的HTML和CSS信息:

This box should be on top
This box should not be on top; IE however seems to create a new stacking context for positioned elements, even when the computed z-index of that element is 'auto'.
body { margin: 0; padding: 0; } #container { position: relative; } #box1 { position: absolute; top: 100px; left: 510px; width: 200px; height: 200px; background-color: yellow; z-index: 20; } #box2 { position: absolute; top: 50px; left: 460px; width: 200px; height: 200px; background-color: lime; z-index: 10; } #content { width: 420px; padding: 20px; } 正常理解是应该显示上图右边的那种情况,但是IE7上的确是一件很怪异的事情,查了许多资料终于找到了解决方案: http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/ > 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. So we giving the parent element a higher z-index actual fixes the bug 以上告诉我们,IE设置了position的元素会生成一个新的stacking context,导致 z-index 为0,所以才失效了。所以我们需要在这个元素的父元素上设置一个更高的z-index值。 在上述的box1中的父元素container设置一个更大的z-index就能解决这个问题,如下: #container { position: relative; z-index:30;} 这一Bug差点搞残我。。。 [1]: https://www.crackedzone.cn/uploads/2011/04/IE7-position.jpg

Nginx 自动禁止爬虫IP采集

### 背景最近我们有一个公开服务提供给客户查询关键词的热度值,由于这个API做在官方网站上,自然没有用户登陆,也没有很高查询成本,所以设计上没有任何鉴权无法进行身份认定,于是就被一个爬虫开了超高并发请求,直接后端的AWS Tomcat CPU被用尽,导致无法响应。爬虫显然...… Continue reading

Redis原子性事务Lua应用

Published on June 28, 2020