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 Adjust the Profile Page and Header

@media query troubleshooting!!

The result of my code displays a large gap between the nav elements and the other page elements. Once I scroll down the page, my images are unaligned and messy. I believe there is something wrong with my @media query but I can't pinpoint where. It should also be noted that when my site is resized to that of a mobile site all elements display in the correct places respective to each other. When I delete all of this second @media query code from my workspaces, my site renders correctly and adjusts correctly for both desktop and mobile viewings. Please explain what is happening here... Here is the code for the second media query for min-width 660px:

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

  #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;
    margin: 45%;
  }

  h1 {
    font-size: 2.5em;
  }

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

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

}


          ```

2 Answers

Billy Bellchambers
Billy Bellchambers
21,689 Points

Hi Ethan.

looking at your coding I would imagine its due to the following.

  #logo {
    float: left;
    margin-left: 5%;
    text-align: left;
    **margin: 45%;** //this margin value is probably pushing all the layout around when the media query is true. Is this supposed to be a width value?
  }
  #logo {
    float: left;
    margin-left: 5%;
    text-align: left;
    **width: 45%;**
  }

This should clear up the bully logo item messing with the rest of your layout when media query is true.

Thank you!