Clearfix

When floats are used for layouts - they need a clearfix solution. This helps prevent layout problems caused by the elements being removed from the block context of the surrounding elements.

Examples

Cleared Floats

This example shows two floated elements wrapped in an element with a 4px solid red border. In the top version where the floats are cleared, the red element wraps around the elements. In the second example - the parent element is collapsed and the two floated elements sit outside of it. It should be noted you don’t have to clear floated elements that are inside another floated element.

UnCleared Floats

Previous

Floats

Next

Display

Reference

MDN - Clears

tachyons-clears

v3.0.4 199 B
Declarations
20
Selectors
20
Max. Specificity Score
11
Size of Avg. Rule
1.0526315789473684
src/_clearfix.css

/*

   CLEARS

*/

/* Nicolas Gallaghers Clearfix solution
   Ref: http://nicolasgallagher.com/micro-clearfix-hack/ */

.cf:before,
.cf:after   { content: " "; display: table; }
.cf:after   { clear: both; }
.cf         { *zoom: 1; }