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
Suzanne Reeve
1,582 Points3 column layout
I want to show a 3-column layout but for some reason there's a gap between the last two pictures. There's also a funny gap when I make the browser smaller and it defaults to a 2 column layout. It's the exact same code as Nick's, but I just added more pics to play around with. Troubleshooting did not work. It should be on my url: suzannereeve.com Please help?
Thanks Suzanne
4 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Suzanne,
In the video for the 3 column layout where :nth-child(4n) was added there's a correction in the Teacher's Notes. The correct expression is 3n + 1
4n works out ok for up to 6 images but breaks down after that.
The problem also exists in the 2 column layout which you noticed. I don't believe this is corrected in the course. You need to use :nth-child(2n + 1) for the 2 column layout
In main.css:
#gallery li {
float: left;
width: 45%;
margin: 2.5%;
background-color: #f5f5f5;
color: #bdc3c7;
}
/* Add this */
#gallery li:nth-child(2n + 1) {
clear: left;
}
In responsive.css you have to correct the nth-child expression but before that you have to remove the clear property from the items in the 2 column layout because it will mess up the 3 column layout.
responsive.css:
#gallery li {
width: 28.3333%;
}
#gallery li:nth-child(2n + 1) {
clear: none;
}
#gallery li:nth-child(3n + 1) {
clear: left;
}
David Curtis
11,301 PointsTry putting in a 3rd picture in the last row and see what happens.
Suzanne Reeve
1,582 PointsI don't think the number of photo's should be an issue, the code is supposed to be dynamic. There's a function to clear left after every 4th child..
Suzanne Reeve
1,582 PointsThanks!!!