CSS: Float-clearing, getting containers to honor the height of floated elements inside of them
Filed Under (General) by Wenbert on 15-10-2007
Tagged Under : css
I accidentally stumbled on this article found at Agile AJAX. It talks about float-clearing, getting containers to honor the height of floated elements inside of them.
Here is a sample CSS code:
-
-
/* float clearing for IE6 */
-
* html #container,
-
* html .classThatNeedsToBeCleared,
-
* html div.anotherClassThatNeedsToBeCleared,
-
* html #someDiv .someClass .yetAnotherClassThatNeedsToBeCleared{
-
height: 1%;
-
overflow: visible;
-
}
-
-
/* float clearing for IE7 */
-
*+html #container,
-
*+html .classThatNeedsToBeCleared,
-
*+html div.anotherClassThatNeedsToBeCleared,
-
*+html #someDiv .someClass .yetAnotherClassThatNeedsToBeCleared{
-
min-height: 1%;
-
}
-
-
/* float clearing for everyone else */
-
#container:after,
-
.classThatNeedsToBeCleared:after,
-
div.anotherClassThatNeedsToBeCleared:after,
-
#someDiv .someClass .yetAnotherClassThatNeedsToBeCleared:after{
-
clear: both;
-
content: ".";
-
display: block;
-
height: 0;
-
visibility: hidden;
-
}
-
-
<div id="container">
-
< div id="rail" style="float: left;">
-
< div id="content" style="float: left;">
-
</div>
Click here for the entire post.