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

Media Querie problem!

Hello, i have a problem adjusting my layout for mobile/tablet versions, i started with the desktop layout wich maybe was a bad idea, but any way.

heres a picture of how it looks like when i resize the browser!

http://imgur.com/obhp3cb

you can see how the links go over the logo and the wraps, my idea is that at 680px the logo and the links are centered, and the links are under the logo, and they stay that way all the way to the smallest screen. but ive tried many things, but i cant seem to fix the problem, i've posted about this before, but i havent got any clear answer.

So if anyone could help me change the code im about to link and explain it so i know whats happening, i would be gratefull.

heres the code for the responsive css!

@media screen and (max-width: 680px) {

    header {
      height: 130px;
    }


  .nav {
    display: block;
      position: absolute;
      width: 50%;
      height: 75%;
       margin-top: 70px;
      margin-right: 20px;
      margin-bottom: 0px;
      margin-left: 20px;

    }

    header img {
      margin: 0 auto;
    }

    .intro-pic {   
      width: 70%;
      height: 85px;

    }


    .quote {

    }

    .copyright p{
      font-size: 16px;
    }



}

AND HERES THE CODE FOR THE STLYE/MAIN CSS

:root {
    font-family: 'Josefin Sans', sans-serif;
    min-height: 98%;
    border-bottom: 40px solid #008B8B;
    border-top: 10px solid #007D7D;
}

body {
    background-color:#0099FF;
    background-image: url('http://i.imgur.com/BiSmXaq.png'), url('http://i.imgur.com/XHuy0NJ.png'), url('http://i.imgur.com/okpRxJU.png');
    -webkit-animation: snow 20s linear infinite;
    -moz-animation: snow 20s linear infinite;
    -ms-animation: snow 20s linear infinite;
    animation: snow 20s linear infinite;
    color: #E6E68A;
    line-height: 1.62;
}


.container {
    max-width: 940px;
    margin: 0 auto;
    padding: 0 5%;
}

h1, h2 {
    margin-bottom: .78em;
    font-weight: bolder;
    font-size: 28px;
    text-shadow: 1px 1px 1px black;

}

p {
    font-weight: bold;
    font-size: 18.88px;
    margin: 1.3em 0;
}

/* LINK SELECTORS!*/

a.Other-links {
    text-decoration: none;
    color: #336633;
}

a.Other-links:hover {
   text-decoration: underline;
   color:#003300;
}

a.nav-links  {

  background-color: #339933;
  margin: 5px 0px 0px 2px;
  padding: 0px 5px 0px 5px;
  border-radius: 15px;
  text-decoration:none;
  color: #fff;
  border: 2px solid black;
}

a.nav-links:hover {
    background-color:#336633;
    padding: 6px 16px 6px 16px; 
    box-shadow: 0px 0px 1px black;

}

a.nav-links.selected {
    background-color:#336633;
}

.nav a {
    padding: 5px 15px 5px 15px; 
    width: 100%;
}

.nav ul  {
    list-style: none;   
    margin: 0px 28px;
    padding: 0;
}

.nav li {
    display: inline-block;
}


.nav {
    text-align: right;
    margin-top: -40px;
    margin-bottom: 40px;
    margin-right: 25px;
    margin-left: 0px;


}

/*--------------------------------*/

.copyright {
    max-width: 100%;
    text-align: center;
    margin-top: 64px;

}

/*HEADER BORDER*/

header {
   float: left;
   margin: 0 0 40px 0;
   padding: 5px 0 0 0;
   width: 100%;
}


header {
    background:#008B8B;
    border-color: #008B8B;

}

header {
    border-bottom: 10px solid #007D7D;
}


.intro-pic {
    display: block;
    margin: auto 30px;
}

.treehouse-logo {
    position: absolute;
    margin-top: 5px;
    width: 150px;
    height: 150px;
    border: 3px solid black;
    border-radius: 30px;
    transition: transform 2s;
    z-index: 1;
}

.treehouse-logo:hover {
    box-shadow: 0px 0px 10px black;
    transform: translateX(130px);
}

.quote {
    display: inline;
    position:relative;
    white-space: pre;
    margin-top: 200px;
    margin-right: 0%;
    margin-left: 2.65%;
    margin-bottom: 0px;
    color: #272727;
    text-shadow: 1px 1px 1px #272727, 1px 1px 1px #272724 ;
    z-index: 0;
}

.smiley {
    position: absolute;
    margin-top: -110px;
    margin-left: 75px;
    height: 20px;
    width: 20px;
}


/*ABOUT PAGE*/

.pic-ofme {
    display:block;
    margin-left: auto;
    margin-right: auto;
    border: 5px solid darkgreen;
    border-radius: 50%;
    box-shadow: 0 0 5px black;
}

.pic-ofme {
    transition: transform 0.4s;
}

.pic-ofme:hover {
    transform: translateY(-20px);
}


.about-secondary > h1{
    text-align: center;
}

.about-text {
    text-decoration: underline;
}

.social-icon {
    display: inline-block;
    width: 40px;
    height: 40px;
    margin-bottom: -20px;
    margin-left: 10px;
    -webkit-transition:all .2s ease-out;
  -moz-transition:all .2s ease-out;
  -ms-transition:all .2s ease-out;
  -o-transition:all .2s ease-out;
  transition:all .2s ease-out;
}

.social-icon:hover {
   -webkit-transform:translate(0px,-12px);
  -moz-transform:translate(0px,-12px);
  -ms-transform:translate(0px,-12px);
  -o-transform:translate(0px,-12px);
  transform:translate(0px,-12px);
}




/*Contact*/


.general-info {
   text-align:center;
   margin: 0 auto;
   width: 100%;
}



.c-text {
    font-weight: bolder;
    font-size: 40px;
    width: 100%;
    text-decoration: underline;
}

a.mail-link {
   text-decoration: none;
    color: #336633;
}

a.mail-link:hover {
   text-decoration: underline;
   color:#003300;
}

If you need more code just comment and say so!

Kind regards // erdrag

Wayne Priestley
Wayne Priestley
19,579 Points

Hi Erdrag,

I've edited your code so it appears correct in your post.

Here is a link to explain how to use Markdown to post your code How to post code

If you look at the bottom of the box when your typing a reply you will see Markdown Cheatsheet that will also explain how to post your code.

You have to make sure you have a bit of space under your last line of text in your post. Then you add three back ticks followed by html or css depending on the type of code your inserting.
Then straight after your last line of code you add another three back ticks.
Remember to leave at least a few lines between any text at the top or bottom of your code.

alt text

Hope this helps.

Wayne Priestley
Wayne Priestley
19,579 Points

Erdrag,

You'll need to post your html too.

Heres the HTML code too!

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="css/normalize.css" type="text/css">
    <link rel="stylesheet" href="css/responsive.css" type="text/css">
    <link href='http://fonts.googleapis.com/css?family=Josefin+Sans:700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="css/style.css" type="text/css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Erdrag Official Website</title>
</head>
  <body>
     <header class="main-header">
        <a href="index.html">
          <img class="intro-pic" src="img/mainlogo.png" title="Home" alt="logo">
        </a>

        <div class="nav">
          <ul>
            <li><a class="nav-links selected" href="index.html">Work</a></li>
            <li><a class="nav-links" href="about.html">About</a></li>
            <li><a class="nav-links" href="contact.html">Contact</a></li>
          </ul>
        </div>
    </header> 

The probable error to your problem is the fact that you use

position: absolute;

try using

display: inline-block;
text-align: right;

After that start playing with the margins. This should not force your nav under your header as a block, and will align it to the right inside of it's parent container.