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 Adding Breakpoints for Devices

Frantyk Andrii
Frantyk Andrii
35,423 Points

I have a problem with that piece of code:

There are my css file code, and that code just spoil design. If I delete it - "@media screen and (min-width: 660px)" and all of are on below, it will work pretty good. If don't do it, my site looks ugly(

@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;
  }


}

Edited to format code.

2 Answers

If this is in Workspaces please post a snapshot. You do that by clicking the camera icon on the upper right of the workspace. Follow the steps until you can copy the URL. Paste it here.

The initial problem you have is called margin collapse. It is fixed with a procedure called clearfix. Add this code after your header css:

header:after {
  content:"";
  display:table;
  clear:both;
  }

There is discussion in this post and a link that describes the problem in detail. You have some other display issues, but this should get you started on the answers. I think you may have some other clearfix issues, but I don't have time to figure everything out.

Frantyk Andrii
Frantyk Andrii
35,423 Points

Wow. It works. Thank you for your help)

review the link in the post I put below. It really explains the issue well.