负边距会导致边框在IE7中消失 [英] Negative margin causes border to disappear in IE7
问题描述
示例: http://jsfiddle.net/xUrDc/
我试图用每个 li
包围边框,宽度只有一个像素。为了使行正确匹配,我在每个 li
上设置 margin-top:-1px
I'm trying to surround each li
with a border exactly one pixel wide. In order that the lines meet properly, I'm setting margin-top:-1px
on each li
(Otherwise the border is too thick between each).
当在调试模式下将浏览器设置为IE7时,顶部的边框消失。任何人都可以告诉我为什么会是这种情况,或者建议一个更好的方式来实现我想要的外观。
When I set my browser to IE7 in debug mode, the border at the top disappears. Can anybody tell me why this might be the case or suggest a better way to achieve the look I want?
推荐答案
忽略可能性以不同的方式,你可以通过添加 zoom:1 到
ul li
修复IE7。
Ignoring the possibility of doing it a different way, you can fix IE7 by adding zoom: 1
to ul li
.
请参阅: http://jsfiddle.net/xUrDc/1 /
为什么这样工作?简而言之,它为IE7中的元素提供了一个名为 hasLayout
的魔法属性,这恰好修复了此错误。
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.
更多信息:缩放:什么bug:1;修复CSS
这篇关于负边距会导致边框在IE7中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!