Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Responsive Layouts Media Queries Understanding Breakpoints

hi can someone explain this css code plz ?

/************************* Clearfix *************************/

.clearfix:before, .clearfix:after { content: " "; display: table; }

.clearfix:after { clear: both; }

.clearfix { *zoom: 1; }

can someone tell what is the :before for and the *zoom:1 ? thanks you

2 Answers

Steven Parker
Steven Parker
231,248 Points

The ":before" selector (more commonly written with two colons, "::before") creates a pseudo-element as the first child of the otherwise selected element. See this MDN page for more information.

The "zoom" property affects the magnification of an element, and a value of 1 means "no magnification". But note that this property is non-standard and is not recommended for use on production sites Consider using "transform: scale()" (details on this MDN page) instead.

In addition to the non-standard "zoom" property, this code appears to have an issue in the definition of ".clearfix::before" being incomplete.

In addition to what Steven said, the * before zoom indicates some CSS hack for .. I think older IE versions (8 or earlier, iirc) So that line *zoom: 1; is only intended to be read by the older IE (rip).