Negative margin causes border to disappear in IE7

北城以北 提交于 2019-12-05 02:11:37

问题


Example: http://jsfiddle.net/xUrDc/

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).

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?


回答1:


Ignoring the possibility of doing it a different way, you can fix IE7 by adding zoom: 1 to ul li.

See: 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.

More info: What bug does zoom:1; fix in CSS?



来源:https://stackoverflow.com/questions/6302395/negative-margin-causes-border-to-disappear-in-ie7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!