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

Having some trouble with this code challenge.

The challenge is:

"Now, clear the left side of every 4th list item in the element with the id of "gallery". Here's a hint: You'll need to write another selector inside of the media query at the bottom of the file, in addition to the one you wrote in the previous step. You'll also need to use the nth-child pseudo selector."

AND MY CODE IS:

@media screen and (min-width: 480px) { #gallery li { width: 28.3333%; }

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

Am I missing something? I can't for the life of me figure this out :(.

5 Answers

#gallery li:nth-child(4n) And not #gallery li:nth-child(4)

Hi Hazem,

Glad you answered this because I was stumped too.

That worked! Do we always add "n" to the back of the number?

yes to select the element you want 3n for the third one 2n for the second one !

Thank you Hazem. I'll remember that :).

You Are Welcome :)