html - IE CSS Fieldset 边框向右延伸太远 : Why?

标签 html css internet-explorer

我在 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/

相关文章:

jquery - Facebook 评论 (html5) 如果在加载后插入到 DOM 上,则不会显示

html - 在 div 的右上角放置一个图像/图标

html - SVG 中的 iframe 未加载

html - 在 jekyll 站点中预览博客文章

css - 如何使用@page block 添加内容

javascript - HighCharts.js 在 IE8 下不渲染图表

javascript - 检测到位置 : fixed; element crosses over another element 时

html - nivo slider 左箭头图片被窃听

html - Internet Explorer 给表格巨大的负宽度

internet-explorer - ControlGetHandle() 和 Internet Explorer 的保护模式