ReDsgn

Tag: Fieldset

Fixing those bleeding backgrounds on fieldsets

by Paul Boutin on Feb.19, 2009, under CSS, XHTML

Ever encounter this IE bug… The issue occurs when you style fieldsets with a background color. The top of the fieldset color will bleed out of the border to the top of the legend. IE pads to the outside of borders and its apparent here when the padding is increased to accommodate a legend which is over the border of the fieldset.

ie fieldset bleed

This is a simple fix that will work in all browsers so no need for special IE Hacks or Conditional Comments.

First add a position: relative; declaration to the fieldset rule so that the absolute positioning of the legend will be relative to its fieldset:

fieldset {
position: relative;
background: #ffffcc;
}

Next, add a new rule for the legend element and set its absolute positioning properties to emulate its current position:

legend {
position: absolute;
top: -.7em;
left: .2em;
}

That’s it… That’s all there is to it.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Find me here!

Social media sites...

Archives

All entries, chronologically...