Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Kiwi Dave
5,541 Points4th item on a column of 3 elements not clearing left in CSS
Hi there guys,
I have racked my brain on this for ages. The forth row with this code is not clearing left. It is often messy depending on the screen size. I have added a clearfix. Still not happening. Here is the code:
#portfolio-gallery li {
width: 28.333333%;
margin: 2.5%
}
#portfolio-gallery li:nth-child(4n) {
clear: left;
}
Any tips?
I have also tried
#portfolio-gallery li {
width: 28.333333%;
margin: 2.5%
}
#portfolio-gallery li:nth-child(4n-4) {
clear: left;
}
I am stumped.
Hope to hear from you guys soon! :)
2 Answers

Dale Severude
Full Stack JavaScript Techdegree Graduate 71,337 PointsTry this:
#gallery li:nth-child(3n + 1) {
clear: left;
}

Dale Severude
Full Stack JavaScript Techdegree Graduate 71,337 PointsThis code snippet is from the https://teamtreehouse.com/library/how-to-make-a-website/responsive-web-design-and-testing/responsive-web-design class, if you want to study on it further.

Jason Anello
Courses Plus Student 94,596 PointsThe teachers notes for this video https://teamtreehouse.com/library/how-to-make-a-website/responsive-web-design-and-testing/build-a-three-column-layout is the one that has the explanation.
Kiwi Dave
5,541 PointsKiwi Dave
5,541 PointsDale. You are legend!
Solved! I have been trying to work that out for days!
That made my night.
Thanks heaps mate!