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 Build a Three Column Layout

Don Shipley
Don Shipley
19,488 Points

nth-child

Using the nth-child from this video works fine on a small screen, however on the larger screen it will float the 4th child left leaving an empty spot after the third child. I tried replacing the (4n) with (3n + 1). If I remove the pseudo it seem to adjust on both the small and larger screen.

@media screen and (min-width: 480px) {

/***************************
Two Column Layout
*****************************/

#primary {
    width: 50%;
    float: left;
}

#secondary {
width: 40%;
float: right;
}

/***************************
setting width larger screens
3 columns margin of 2.5%
3 * 5 = 15
100% - 15 = 85%
85 / 3 = 28.33333333    
*****************************/

/***************************
Portfolio page
*****************************/
#gallery li {
width: 28.3333;
}
#gallery li:nth-child(3n + 1) {
clear: left;

}

}

2 Answers

Don Shipley
Don Shipley
19,488 Points

I found my mistake.. I left off the % sign on the width. 28.3333% Thank you for your response.

Michael Mangan
Michael Mangan
9,164 Points

can you post the css on the gallery element

Don Shipley
Don Shipley
19,488 Points

I found my mistake.. I left off the % sign on the width. 28.3333% Thank you for your response.