What are the various clearing techniques and which is appropriate for what context?
Topics
CSS
- Empty
divmethod:<div style="clear:both;"></div>. - Clearfix method: refer to the
.clearfixclass. overflow: autooroverflow: hiddenmethod: the parent will establish a new block formatting context and expand to contain its floated children.
Prefer
.clearfix in larger projects
In large projects, having a utility .clearfix class is very helpful. overflow: hidden might clip children if they are taller than the parent, which is not ideal.