Hi,
The only way of doing this without hacks is to give your imortant class a width.
Otherwise the default behaviour of backgrounds and borders alongside floated elements is for the background and border to extend under the float. Floats only add padding to the content and not the background of the content.
IE usually does clear its backgrounds automatically but that is the wrong behaviour according to the specs.
IF you cant set a width on .important (for some reason) then I can only offer hacks for ie and mozilla.
Code:
.important {
margin: 0px 15px 0px 15px;
padding: 0px 5px 0px 5px;
background-color: #FFC;
border: 1px solid #CCC;
overflow:auto;
}
/* commented backslash hack v2 \*/
* html .important {height:1%;}
/* end hack */
Adding overflow:auto to an element next to a float causes mozilla to clear the content and the background automatically. The height :1% gives ie layout (haslayout) and it works as it normaly does.
However opera will not be so kind and will only move out of the way with a width.
Sorry but thats all the solutions I know to this behaviour.
Paul
Bookmarks