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 trialKevin Liu
5,589 PointsClearfix ?
What about .clearfix {display: inline-block;}
Is it a better than using nth-child ()
thank you
1 Answer
Erik Nuber
20,629 PointsThese are for two different purposes. Clearfix allows you to correct collapsing floats. nth-child() is a selector that allows you to select a certain pattern you provide like nth-child(2n+1) will select every odd item. So they aren't relatable as far as I know. Just to be clear about why it would grab the odd item,
2x0 + 1 = 1
2x1 + 1 = 3
2x2 + 1 = 5...etc
Kevin Liu
5,589 PointsKevin Liu
5,589 Pointsoh. make sense. Thanks Erik. the thought process on the odd item is very useful.
I just started Treehouse, long way to go~
Cheers,