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

HTML How to Make a Website Responsive Web Design and Testing Build a Three Column Layout

Matthew Largent
Matthew Largent
1,788 Points

3 columns aren't re-arranging as 2 columns in small screen.

The 3 columns should re-arrange into 2 when the screen gets small enough. Mine remains as 3 columns in a small screen...What's going on?

7 Answers

Hi Matthew,

Can you post your entire responsive.css file? It would be best to post it as a comment to your question.

Are you resizing your browser down to below 480px to see the 2 columns?

Did you correctly have a 2 column layout before you created the 3 column layout in responsive.css?

I would make sure that you have your 3 column layout width, the 28.3333%, inside the 480px media query. If it's outside that media query then it would simply override the 45% width (2 column layout) and could be one explanation why you always have 3 columns now.

Matthew Largent
Matthew Largent
1,788 Points

Solved! The 3 column code was sitting outside of the media query braces. Thanks Jason!

You're welcome.

Gina Bégin
PLUS
Gina Bégin
Courses Plus Student 8,613 Points

Matthew Largent, Jason Anello — can you explain where that media query is? Apologies if I should I open a new post for this question, but it's the exact same question as Matthew's and if I knew where the media query was, I can fix it also. Thanks!

Matthew Largent
Matthew Largent
1,788 Points

Hi Gina, Just to make sure we're on the same page, this issue came up when I was learning the track "Web Design", course "How to Make a Website", the 8th class called "Responsive Web Design and Testing", video "Build a Three Column Layout".
In the video just before that one, which is "Adding Breakpoints for Devices", it had you make a file called responsive.css. Eventually through the course you'll have two media queries, though your 2-to-3 column code will be in the uppermost one, beginning with "@media screen and (min-width: 480px) { }". Inside those curly braces should be the code which I'll paste here:

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

#gallery li {
  width: 28.3333%
}

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

Also, I just learned now that if too many tabs are open in Chrome, it won't allow the screen to get small enough to reach the breakpoint where 3 columns collapse into 2. It was a little frustrating before I realized it wasn't my code that was the problem this time.

Gina Bégin
PLUS
Gina Bégin
Courses Plus Student 8,613 Points

Thanks so much for the reply, Matthew Largent! That is frustrating — I use Chrome also!

So my code is a bit different, but on purpose: If you look at the "Teacher's Notes" in the page for that course (same as the one you were talking about) you'll see that Nick Pettit said that there was a fix to the code http://teamtreehouse.com/library/how-to-make-a-website/responsive-web-design-and-testing/build-a-three-column-layout

Supposedly the code doesn't work as shown in the video if there are more than those 5 images that were provided to us added to the page. My page will have more than five, so I decided to use the code that was supposed to be more correct/robust.

Now I'm wondering if the updated code is the reason I'm not getting it down to 2 columns when it's resized, since I took your advice and made my test site its own window so it wasn't competing with tabs...

Now I feel really lost!

Gina Bégin
Gina Bégin
Courses Plus Student 8,613 Points

Think it might be time for me to start a new thread about this because of the code correction? I suppose it anyone else caught the "teacher's note" they might also be having difficulty.

Hi Gina,

Probably the easiest thing to do is paste your entire responsive.css file here and we can take a look at it. If you decided to start a new thread and you still need help there then post it here and I'll try to help you in the new one.

The 3n + 1 expression that you added doesn't affect the 2 column layout so you don't have to worry about that. It was simply a correction so that it could handle the general case of an unknown number of images I would say that you either have the 3 column code outside of the 480px media query or you have the other problem that Matthew mentioned where maybe you're not getting the browser width below 480px.

One thing that you can do is temporarily put the following in your 480px media query:

body {
  background: orange;
}

If you see the orange go away when you shrink your browser width down then you know you're below 480px. If you're still seeing 3 columns at that point then it's likely you have your 3 column styles outside the media query.

Gina Bégin
PLUS
Gina Bégin
Courses Plus Student 8,613 Points

You got it Jason Anello! The orange was working, so I knew I had the right size, so it had to be the media queries. It was that the "}" for both the 480 and 660 media queries weren't surrounding the code they were supposed to cover, which I didn't know they had to do. I'm surprised I missed both of those — I usually am off because of a typo, not a big mistake like that since I am following along word-for-word! Sheesh.

This means you actually fixed two problems; this one as well as what was going on over here: https://teamtreehouse.com/forum/struggling-on-this-one-nav-lis-fall-under-each-other-logo-area-is-way-up-high-still

Gina Bégin
Gina Bégin
Courses Plus Student 8,613 Points

Wish there was a way to give you the "Best Answer" over there! :)

Glad you got it all figured out.

I would suggest that you mention in your other thread that the problem is solved and briefly mention the solution so that others finding your thread with a similar problem will know what the solution was.

I suppose you could leave an answer there and assign "best answer" to yourself. If you don't want to do that then at least put "[SOLVED]..." at the beginning of your question title so others helping in the forums will know you don't need any more help.

Gina Bégin
PLUS
Gina Bégin
Courses Plus Student 8,613 Points

Hey Jason Anello,

Sorry to open this back up, but just saw that it's doing the same thing in Firefox that I described here (I was in Chrome before, where it works perfectly) — but it only does it for a split second as I'm sizing — you know unless I find the exact size where it's breaking strangely. I'm not sure how to find that exact size where the link is falling under in the navigation, but do you know why it might be doing it in Firefox and not in Chrome? I know each browser has its differences.

Hi Gina,

If this is about your other thread you linked to then I would recommend that you issue an update to the problem over there in order to keep this thread focused on the original problem. I have subscribed to the other one and can try to help you over there. I would re-post your current responsive.css file in the other thread and explain what changes you've made and what the current problem is.

Firefox has a web developer tool called "responsive design view". You can access it on windows with Ctrl+Shift+M or through the menu: Tools -> Web Developer -> Responsive Design View

You can leave your browser maximized when you use this tool. It puts your webpage in it's own resizable frame which you can drag and change the dimensions of. It shows you the dimensions so that you'll be able to drag until you see your problem and then you'll know the exact width where you're having your problem.