[英]Negative margin causes border to disappear in IE7
Example: http://jsfiddle.net/xUrDc/示例: http://jsfiddle.net/xUrDc/
I'm trying to surround each li
with a border exactly one pixel wide.我试图用一个像素宽的边框包围每个
li
。 In order that the lines meet properly, I'm setting margin-top:-1px
on each li
(Otherwise the border is too thick between each).为了使线条正确相遇,我在每个
li
上设置margin-top:-1px
(否则每个之间的边框太厚)。
When I set my browser to IE7 in debug mode, the border at the top disappears.当我在调试模式下将浏览器设置为 IE7 时,顶部的边框消失了。 Can anybody tell me why this might be the case or suggest a better way to achieve the look I want?
谁能告诉我为什么会出现这种情况或建议一种更好的方法来实现我想要的外观?
Ignoring the possibility of doing it a different way, you can fix IE7 by adding zoom: 1
to ul li
.忽略以不同方式进行操作的可能性,您可以通过将
zoom: 1
添加到ul li
来修复 IE7。
See: http://jsfiddle.net/xUrDc/1/见: http://jsfiddle.net/xUrDc/1/
Why does this work?为什么这行得通? In short, it provides a magical property known as
hasLayout
to the element in IE7, which happens to fix this bug.简而言之,它为 IE7 中的元素提供了一个名为
hasLayout
的神奇属性,恰好修复了这个 bug。
More info:What bug does zoom:1;更多信息:缩放有什么错误:1; fix in CSS?
修复 CSS?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.