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

Trent hand
Trent hand
7,402 Points

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

Hazem mosaad
Hazem mosaad
15,384 Points
#gallery li:nth-child(4n) And not #gallery li:nth-child(4)
Ashby Bernardino
Ashby Bernardino
940 Points

Hi Hazem,

Glad you answered this because I was stumped too.

Trent hand
Trent hand
7,402 Points

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

Hazem mosaad
Hazem mosaad
15,384 Points

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

Trent hand
Trent hand
7,402 Points

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