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

Refactor the Layout: Challenge: Task 2 of 2 -- nth-child Not Working - Help

The question is: Inside the media query, clear the left side of every 4th list item in the gallery.

My Code:

gallery li {

width: 28.3333%;

}

#gallery li.nth-child(4n) { clear:left; }

1 Answer

If you are selecting the nth-child of the list item use a colon after the li selector.

li:nth-child(4n){
    clear: left;
}

if you are selecting the nth-child of the list use the ul selector

ul:nth-child(4n){
    clear: left;
}

or if gallery is the id of the list

#gallery:nth-child(4n) {
    clear: left;
}

Thank you very much Preston!

You're welcome.