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

Images and navigation are placed wrong when making browser smaller!

Hey, when i make my browser smaller the navigation and images are rezising heres a picture of it

http://imgur.com/7caAt4f

and heres my code for Main.css index.html and the media@ css

#gallery li:nth-child(2n+1) {
  clear:left;  ```
}
 ```@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(2n+1) {
     clear: none; ```

  }

   ```#gallery li:nth-child(3n+1) {
    clear:left; ยดยดยด
  }


/**********************************************
MAIN CSS, STYLING OF THE WEBSITE
***********************************************/

body { font-family: 'Lora', serif; ```

}

html { min-height: 98%; border-bottom-color: #599a68; border-bottom-style: solid; border-bottom-width: 40px; }

/*Makes the whole div section, have max-width of 940px, with margin 0 , auto and a padding of: 0, 5% */ #wrapper { max-width: 940px; margin: 0 auto; padding: 0 5%; }

/makes the underline disapear, and while clicking, you get pointer/ a { text-decoration: none; cursor: pointer; }

img { max-width: 100%; }

h3 { margin: 0 0 1em 0; }

/**************************************** HEADING *****************************************/

/* margin moves it 30px to the bottom*/ header { float: left; margin: 0 0 30px 0; padding: 5px 0 0 0; width: 100%;

}

/Makes the text in the header align center, and with margin 0/ #logo { text-align: center; margin: 0; width: 50%; }

h1 { font-family: 'Sansita One', cursive; margin: 15px 0; font-size: 2.0em; font-weight: normal; line-height: 0.8em; text-shadow: 2px 1px 1px black; }

 h2 {
  font-size: 1em;
  margin: -5px 0 0 15px;
  font-weight: normal;
  text-shadow: 1px 1px 1px black;  
}

/**************************************** NAVIGATION *****************************************/

 nav {
 text-align: center;
  padding: 10px 0;
  margin: 20px 0 0;  ```
}

 ```nav ul {
  list-style: none;
  margin: 0 10px;
  padding: 0; ```
}

 ```nav li {
  display: inline-block; ``` 
}

 ```nav a {
  font-weight: 900;
  padding: 15px 10px; ```  
}

/**************************************** FOOTER *****************************************/

 footer {
  font-size: 1.2em;
  text-align:center;
  clear: both;
  padding-top: 50px;
  color: #989898; ```

}

 ```.social-icon {
  width: 35px;
  height: 35px;
  margin: 0 5px; ```
}

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

#gallery { margin: 0; padding: 0; list-style: none; }

#gallery li { float: left; width: 45%; margin: 2.5%; background-color: #f5f5f5; color: #bdc3c7; }

#gallery li a p { margin: 0; padding: 5%; font-size: 0.8em; color: #898989; text-shadow: 0.2px 0.2px 0.1px grey; }

/Change the look of the images in portfolio/ .images { border-radius: 5px; border: 10px solid; border-color: lightgreen; }

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

.profile-photo { display: block; max-width: 150px; margin: 0 auto 30px; border-radius: 100px; border: 7px solid lightgreen; }

  position: relative;
  top: 40px; ```

}

/****************************************
PAGE: CONTACT
*****************************************/

 ```.contact-info {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9em;  ``` 

}

 ```.contact-info a {
  display: block;
  min-height: 20px;
  background-repeat: no-repeat;
  background-size: 20px 20px;
  padding: 0 0 0 30px;
  margin: 0 0 10px; ```
}

 ```.contact-info li.phone a {
  background-image: url('../img/phone.png'); ```
}

 ```.contact-info li.mail a {
  background-image: url('../img/mail.png'); ```
}

 ```.contact-info li.twitter a {
  background-image: url('../img/twitter.png'); ```
}


 ```h3 {
  text-decoration: underline; ```
}

/**************************************** PAGE: OTHER *****************************************/

/****************************************
COLORS
*****************************************/

/* Change the body background to white, and the text to grey*/
 ```body {
  background-color: #fff;
  color: #999; ```
}


/* Changing the headers background to green and the border color to dark green*/
 ```header {
  background: #6ab47b;
  border-color: #599a68; ```
}


/* nav background on mobile*/
 ```nav {
 background: #599a68; ```
}

/* LOGO TEXT*/
 ```h1, h2 {
  color: #fff; ```
} 

/*Change the link colors to Green*/
 ```a {
  color: #6ab47b; ```
}

/* nav visited*/
 ```nav a, nav a:visited {
 color: #fff; ```
}

/* selected nav link*/
 ```nav a.selected, nav a:hover {
  color: #32673f; ```
}

INDEX HTML

    <meta charset="utf-8">
    <title>Erdrag | Web Designer</title>
        <link rel="stylesheet" href="css/normalize.css">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700Sansita+One' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/responsive.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <header>
            <a href="index.html" id="logo">
        <h1>Erdrag</h1>
                <h2>Web designer</h2>        
            </a>
            <nav>
                <ul>
                    <li><a href="index.html" class="selected">Portfolio</a></li>
                    <li><a href="about.html">About</a></li>
                    <li><a href="contact.html">Contact</a></li>
          <li><a href="other.html">Other</a></li>
                </ul>
            </nav>
    </header>
        <div id="wrapper">
                <section>
                    <ul id="gallery">
                        <li>
                            <a href="img/numbers-01.jpg">
                                <img src="img/numbers-01.jpg" alt="" class="images">
                                <p>Experimentation with colors textures</p>
                            </a>
                        </li>
                        <li>
                            <a href="img/numbers-02.jpg">
                                <img src="img/numbers-02.jpg" alt="" class="images">
                                <p>Playing with blending modes.</p>
                            </a>
                        </li>
                        <li>
                            <a href="img/numbers-06.jpg">
                                <img src="img/numbers-06.jpg" alt="" class="images">
                                <p>Trying to create an 80's style</p>
                            </a>
                        </li>
                        <li>
                            <a href="img/numbers-09.jpg">
                                <img src="img/numbers-09.jpg" alt="" class="images">
                                <p>Drips created using photoshop.</p>
                            </a>
                        </li>
                        <li>
                            <a href="img/numbers-12.jpg">
                                <img src="img/numbers-12.jpg" alt="" class="images">
                                <p>Creating shapes using repetitions.</p>
                            </a>
                        </li>

                    </ul>
                </section>
                <footer>
                    <a href="http://twitter.com/erdrag"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
                    <a href="http://facebook.com/erdrag"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
                    <p>&copy; 2014 Erdrag.</p>
                </footer>
      <span id="bottom-links">
        <a href="#logo">Go back up!</a>
        <a href="#logo">Credits!</a>
      </span>
            </div>
  </body>
</html>```

4 Answers

I'd say make sure that the nav elements are display: inline-block and that you give the images some margin.

This initially looks like maybe your media queries are being applied? Could you paste those up here so we can have a look?

Are you using min-width or max-width in your media queries?

heres the media querie code

the thing i have the most problem with is the navigation links, because they change places

the images does not overlap eachother anymore, because i changed border size on them

look at these images and see the behaviour of my website

http://imgur.com/a/AJiVf (scroll down to see all of the images)

gallery li:nth-child(2n+1) {

clear:left; } @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(2n+1) { clear: none;

}

#gallery li:nth-child(3n+1) { clear:left; }

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

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

}

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

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


nav {
display: inline-block;
  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: 10px solid #599a68;
  margin-bottom: 65px;
}

Ok cool,

Have you tried:

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

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

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

As opposed to your current #gallery li:nth-child(3n + 1) rules? Try the replacing with the code above and see how that looks.

Hope that helps,

Let me know how you get on!

i replaced the 3+1 with 4n, but it didnt help, hmm, any more ideas`?

i still have the problem with the links

ive looked on many different sites, about how to get this fixed, but i cant seem to find any solutions ;/ hmmm