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 trialEmily Salm
1,366 Pointsnth-child code challenge
Hi - The code challenge that I am doing asks me to clear the 4th item of every list item in the gallery (in the media query). Here is what I wrote:
gallery li.nth-child (4) {
clear: left;
}
It continues to error every time I submit this. Can someone please point out what I am doing wrong? Thank you!
Emily
Emily Salm
1,366 PointsRichard Duncan - I was getting "Bummer!!" (How irritating!) Anyhow - all is resolved now.
Jason Anello
Courses Plus Student 94,610 PointsThe instruction say "Inside the media query, clear the left side of every 4th list item in the gallery."
I'm surprised that it passes with :nth-child(4)
This could be a bug. This only clears the 4th item, not every 4th list item.
I feel it should be :nth-child(4n)
4 Answers
rayorke
27,709 PointsHi Emily!
nth-child is a pseudo-class. Pseudo-classes are added to the selector with a colon ":" rather than a period "." Also, make sure there isn't a space between the pseudo-class and the argument.
So, it would look something like the following (without giving away the complete answer):
li:nth-child(4)
I hope that helps!
Andrew Shook
31,709 PointsMake sure you put you have a "#" in front of gallery and a colon needs to be put between "li" and "nth-child".
James Ingmire
11,901 PointsHi Emily, try this:
.gallery ul li:nth-child(4)
{
clear: left; //are you sure its clear:left not both?
}
Emily Salm
1,366 PointsThanks all for the feedback! The hashtag and colon resolved everything.
Richard Duncan
5,568 PointsRichard Duncan
5,568 PointsIs there an error or are you just getting "Bummer!!" ? Have you tried a different property value such as clear: both;