views:

355

answers:

2

I have a fieldset inside of a fieldset. Each type of fieldset changes color when hovered over. Works great in Firefox, but in IE8 and IE8 in IE7 compat mode, when I hover over the child fieldset, it jumps (it looks like some padding gets removed, but that's not what my css says).

Can someone help me figure out how to prevent the jumpy effect in IE? Why does the child fieldset jump when hovered over, but not the parent fieldset?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <style type="text/css">
        fieldset.property { background-color: #EDF5FF; }
        fieldset.property:hover { background-color: #C1DDFF; }
        fieldset.service:hover { background-color:#EDF5FF; }
    </style>
</head>
<body>
    <fieldset class="property">
        Parent fieldset<br />
        Parent fieldset<br />
        Parent fieldset<br />
        <fieldset class="service">
            Child<br />
            Child<br />
            Child<br />
        </fieldset>
        Parent fieldset<br />
        Parent fieldset<br />
        Parent fieldset<br />
    </fieldset>
</body>

A: 

I still don't know why IE8 makes the child jumpy, but I found the fix:

If I add a style to explicitly set the padding on a fieldset, the fieldset stays the same when hovered over:

/* Add to make rendering in IE and Firefox the same /*
fieldset { padding:2px; }
slolife
+3  A: 

I, too, am unsure exactly why IE treats child elements this way but by specifically defining the padding and often times, the margins as well, this can be prevented.

fieldset {margin:0; padding:0;}

Slevin
Anyone know if this is considered a bug in IE or is this by design?
slolife
I wouldn't consider this to be a bug. Each browser renders margins and padding differently. By defining a specific value for both attributes though, each browser will render according to the CSS.
Slevin
Different padding/margins are not a bug. That's fine by me, and will teach me to use a reset css in the future. The jumpy child fieldset on hover seems to be a bug IMO.Anyway, thanks for the help
slolife