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

Mobile Device is displaying 3 collums instead of 2

Hello everyone! Was looking at the code and i cant find the problem why on mobile it is displaying 3 collums instead of 2 , this is the code from responsive css :

responsive.css
  @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%;
  }


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


/**************************************
PAGE: ABOUT
**************************************/


.profile-photo {
  float: left;
  margin: 0 5% 80px 0;
  }


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


/**************************************
HEADER
**************************************/


nav {
  background: none;
  float: right;
  font-size: 1.125em;
  margin-right: 5%;
  text-align: right;
  width: 45%;
  }


#logo {
  float: left;
  margin-left: 5%;
  text-align: left;
  width: 45%;
  }


h1 {
  font-size: 2.5em;
  }


h2 {
  font-size: 0.825em;
  margin-bottom: 20px;
  }


  header {
  border-bottom: 5px solid #599a68;
  margin-bottom: 60px;
  }



}

5 Answers

Okay, so if you mean the #gallery items on the homepage, you need to include the #gallery li and .profile-photo rules inside the min-width: 480px media query (i.e. move the closing curly brace to under the .profile-photo rule):

responsive.css
@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%;
  }


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


/**************************************
PAGE: ABOUT
**************************************/


.profile-photo {
  float: left;
  margin: 0 5% 80px 0;
  }

}

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

That first media query is for anything 480px or wider, so your typical 'mobile' device in portrait mode won't use any of the CSS within that or the other media query, and will instead just use whatever is in the other stylesheet.

But in the course when the browser window was resized it was on 2 collums, but on mine its 3 :S

Can you please share a Snapshot of your Workspace so we can see all of the code, not just this one file?

Thanks , worked , I was looking at the code I didnt notice that curly brace was not put where it should