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 How to Make a Website Responsive Web Design and Testing Refactor the Layout

challenge task 2 of 2 correction

Why don't you accept the corrected code as well as what was shown in the video for the second task on this code challenge? I'm referring to the nth-child correction which is corrected below.

#gallery li:nth-child(3n+1) { clear: left; }

1 Answer

Máté Végh
Máté Végh
25,607 Points

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

That means you want to begin the cycle from the 4th item, then select every 4th item from there. 4n+4 will do that for you:

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

Or you can use 4n+0 as well. It selects every 4th item up from 0, which results the same as 4n+4:

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

In these cases, when the offset value is 0, you can also use 4n, which does the same as 4n+0:

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

I also suggest you to read some articles for better understanding:

Hope I could help.