We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

marcio on 02/26/08


Tagged

css clearfix


Versions (?)


Who likes this?

8 people have marked this snippet as a favorite

basicmagic
adix
SpinZ
wbowers
mifly
rouxmout
chill3d
hannizkaos


Clearfix CSS Hack


Published in: CSS 


URL: http://perishablepress.com/press/2008/02/05/lessons-learned-concerning-the-clearfix-css-hack/

  1. /* slightly enhanced, universal clearfix hack */
  2. .clearfix:after {
  3. visibility: hidden;
  4. display: block;
  5. font-size: 0;
  6. content: " ";
  7. clear: both;
  8. height: 0;
  9. }
  10. .clearfix { display: inline-block; }
  11. /* start commented backslash hack \*/
  12. * html .clearfix { height: 1%; }
  13. .clearfix { display: block; }
  14. /* close commented backslash hack */

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: LadynRed on March 3, 2008

It should be noted that the * html hack will cause IE7 to choke.

You need to login to post a comment.