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

Nth-child Selector

In the challenge I'm being asked:

Clear the left side of every 4th list item in the element with the id of "gallery". 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.

Attached is the code the challenge is telling me is incorrect. Please help!!!!

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

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

3 Answers

Krzysztof Kucharzyk
seal-mask
.a{fill-rule:evenodd;}techdegree
Krzysztof Kucharzyk
Front End Web Development Techdegree Student 4,005 Points

Your code looks good besides this lil space between li: and nth-child(4n)

  #gallery li: nth-child (4n) { /* remove space between li: and nth-child(4n) */
    clear: left;
  }
  #gallery li:nth-child (4n) {
    clear: left;
  }

The challenge is still saying I did it incorrectly. I contacted the support team. May be a programming issue or something. Thanks!!!

Kristopher Van Sant
PLUS
Kristopher Van Sant
Courses Plus Student 18,830 Points

Hi! In addition to what Krzysztof Kucharzyk said, you also need to remove the white space between nth-child and (4n)

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

THANK YOU BOTH! Finally got it! Lol