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 trialbelen almonacid
8,495 Pointsproblems with nth-child
HI, im having problems with the nth-child 3n+1 ... when i maximize the page its works perfect with the 3 column display and when i minimize it as well but between 413px and 440px there's again the weird jump with the images...in the portfolio page..
@media screen and (min-width:480px) {
/*********************************
PAGE:CONTACT - two column layout
**********************************/
#primary {
width:50%;
float: left;
}
#secondary {
width: 40%;
float: right;
}
/*********************************
PAGE:PORTFOLIO
**********************************/
#gallery li {
width: 28.333333%;
}
#gallery li:nth-child(3n+1){
clear:left;
}
}
5 Answers
Josue Maridueña
16,814 PointsSo the problems happens in 480px only?
belen almonacid
8,495 Pointsthe problem is between 413px and 440px when i make the page smaller between those sizes. When it changes from 3 columns to 2 columns. At 2 columns, between those sizes, my 3rd li element moves to the right because my 1st li element has a 2 row caption. At 480+px the display works fine.
Josue Maridueña
16,814 PointsYou need to change the nth-child (3n+1) to (2n) in 413px to fix dat i believe, because you are selecting the third element in a column of two elements :)
belen almonacid
8,495 Pointsi tried that already and it fix this problem but now when i maximize the screen it only has 2 columns and images start to jump again.
(thank you for your help btw!)
Michael Cabrera
3,518 PointsI'm having the same problem as Belen. The (3n+1) or (2n) solution did not work for me either.
belen almonacid
8,495 PointsI solved it!!! I add the following:
@media screen and (max-width 440px) { gallery li:nth-child (2n+1) { clear:left: } }
In this formula i use the max width instead of the min-width for 440 px and solved the problem. I added after the "@media screen and (min-width 480px)