简体   繁体   English

HTML字段集的边框与图例重叠

[英]Border of HTML fieldset overlaps legend

So I have an HTML fieldset and legend, and had issues with the background-color in the fieldset spilling outside of the borders in IE7. 所以我有一个HTML字段集和图例,并且在IE7中边界之外的字段集中出现background-color问题。 I was able to resolve the issue by using negative margins, like so: 我能够通过使用负边距解决问题,如下所示:

fieldset {
    background-color:#E6E2D7;
    padding-top:5px;
    position:relative;
}

fieldset legend {
    position: absolute;
    top: -0.6em;
    left: 0.5em;
}

Now the border of the fieldset crosses over the legend in IE8+/Firefox/Chrome, but looks fine in IE7. 现在,fieldset的边框跨越IE8 + / Firefox / Chrome中的图例,但在IE7中看起来很好。

Is this a known issue and if so, is there a workaround? 这是一个已知问题,如果是,是否有解决方法?

Below is a link to a screenshot of the issue: 以下是该问题截图的链接:

截图

You can have an IE7 specific css class by adding * + html before its definition 您可以通过在定义之前添加* + html来拥有IE7特定的css类

Example: 例:

/* IE7 specific css*/
* + html fieldset legend {
    position: absolute;
    top: -0.6em;
    left: 0.5em;
}

/* all other browsers*/
fieldset legend {
    position: absolute;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM