我在 HTML 中定义了一个字段集,并对其应用了以下(简单的)CSS 规则:
fieldset
{
margin: 2em 0;
position:relative;
padding: 1em;
border:1px solid #ccc;
}
一切都很好,没什么大不了的,除了在 IE 的所有版本(嗯,据我所知最多 7 个)中,字段集的顶部边框——但有趣的是,底部边框在视觉上也延伸了向右移动约 25 像素,超出垂直边框在那一侧的位置。
值得注意的是,例如在 Firebug 中查看时,该元素的宽度使其在宽度方向上位于其父元素之外。
是什么导致了 IE 中的这个问题?这是一个已知问题吗?如果是,修复/破解/解决方法是什么?
最佳答案
我已经为此苦苦挣扎了一段时间;今晚我终于找到了答案。
http://www.sitepoint.com/forums/showthread.php?t=526881
引用 NatalieMac 的话:
Seems that if you have an element inside the fieldset that's overflowing to the right of the fieldset, it extends the top border. I had a container set to a width of 100% with no padding or margins which IE7 thought was overflowing for some reason (even though the content inside this container was right-aligned and viewable within the border of the fieldset).
I was able to fix it just by adding overflow:hidden to the fieldset.
我可以确认这确实也解决了我的问题。
关于html - IE CSS Fieldset 边框向右延伸太远 : Why?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/248483/