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

Aditi Jain
Aditi Jain
1,217 Points

drifting images of the gallery

When I did exactly as Nick told,

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

it worked fine. But when I increased the description of the first image by a few lines in index.html's gallery, the third and the fourth images drifted to the right hand side again at different browser window sizes.

P.S. the code is same as Nick's.

3 Answers

Alessandra Vaughn
Alessandra Vaughn
13,915 Points

Hi Aditi,

Are you having the issue when the images are 2 across and the width of the browser window is around 300-ish pixels wide? I have this issue as well. I don't think it was addressed in the video. I fixed it by adding an additional media query for a screen width of 479 pixels or less. See code below.

@media screen and (max-width: 479px) {
  /* two-photo layout */
  #gallery li {
    width: 42.5%
    }

  #gallery li:nth-child(3n) {
    clear: left;
    }
}
Aditi Jain
Aditi Jain
1,217 Points

Hi! Thanks for the code. It did fix the issue.Thanks for the idea! :)

Anyways, quick question: why did we make 2 column layout when we were fitting 3-images per row? Code is pasted below:

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

/******************************************************* TWO COLUMN LAYOUT *******************************************************/

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

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

/******************************************************* PAGE: PORTFOLIO *******************************************************/

#gallery li{ width: 28.3333%; } }

Alessandra Vaughn
Alessandra Vaughn
13,915 Points

Hi - I'm glad the code worked. I think that "two-column layout" code is for the contact page, not for the gallery.