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
Kamil Acero
2,513 PointsProblem with code?
a { text-decoration: none; }
wrapper {
max-width: 940px; margin: 0 auto; }
logo {
text-align: center; margin: 0; }
h1, h2 { color: #fff; }
nav a { color: #fff; }
nav a:hover { color: #32673f; }
h1 { font-family: ‘Changa One’, sans-serif; font-size: 1.75em; font-weight: normal; }
img { max-width: 100%; }
gallery {
margin: 0; padding: 0; list-style: none; }
gallery li {
float: left; width: 45%; margin: 2.5%; background-color: #f5f5f5; color: #bdc3c7; }
nav ul { list-style: none; margin: 0 10px; padding: 0; }
nav li { display: inline-block; }
nav a { font-weight: 800; padding: 15px 10px; }
.profile-photo { display: block; margin: 0 auto 30px; max-width: 150px; border-radius: 100%; }
.contact-info { list-style: none; padding: 0; margin: 0; font-size: 0.9em; }
.contact-info a { display: block; min-height: 20px; background-repeat: no-repeat; background-size: 20px 20px; padding: 0 0 0 30px; margin: 0 0 10px; }
@media screen and (min-width: 480px) { #gallery li {
width: 28.3333%; } #gallery li: nth-child(4n) { clear: left; } }
7 Answers
Dylan Macnab
24,861 PointsHey Kamil, I made two changes to your code.
I used :nth-of-type -- which is slightly different than nth-child. Either may work for this question but I did not try nth-child.
I wrote the nth-of-type rule to apply to all list items, not just the list items that are child elements of the gallery. It's a less specific version of the same rule.
Your written code should look like this:
@media screen and (min-width: 480px) {
#gallery li {
width: 28.3333%;
}
li:nth-of-type(4n) {
clear: left;
}
}
Hope that helps!
Kamil Acero
2,513 PointsI am trying to finish the how to create a website first part of the track but it keeps telling me that the css code for the 4 child is wrong.?
erdragerdragsson
Courses Plus Student 5,887 Pointstry nth-child(4) instead
Kamil Acero
2,513 PointsI tried that but it does not work.
Dylan Macnab
24,861 PointsHi Kamil, post the link to the challenge and I can try to solve it.
Kamil Acero
2,513 PointsThanks dylan,
here is the link to the challenge http://teamtreehouse.com/library/refactor-the-layout
i have not problem with the first questions but on the second it keeps telling there is an error even though i believe the code is correct..
Thanks a lot
erdragerdragsson
Courses Plus Student 5,887 Pointsi passed the challenge with this code without the #gallery before it
li:nth-child(4n) { clear:left;
}
i hope this helps!
Kind regards // erdrag
Kamil Acero
2,513 Pointsthank you both for the help. The problems seemed to be the fact that i had a space
The incorrect code:
gallery li: nth-child(4n) {clear: left;}
The correct code: