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 How to Make a Website Sharing a Website Review: Sharing a Website

hilary ledoan
hilary ledoan
3,533 Points

How to center my navigation on a mobile device

When I make my screen smaller (or use my mobile device), the navigation (portfolio, about, contact) does not center, nor is there a bar (like the one in the video).

Here is my index.html and responsive.css

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Hilary | UX Designer</title>
        <link rel="stylesheet" href="css/normalize.css">
        <link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' 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">
      </head>
      <body>
        <header>
          <a href="index.html" id="logo">
            <h1>Hilary Ledoan</h1>
            <h2>UX 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>
            </ul>
          </nav>
        </header>
        <div id="wrapper">
        <section>
          <ul id="gallery">
            <li>
              <a href="img/background.png">
                <img src="img/background.png" alt="">
                <p>Trying to create a vintage look.</p>
              </a>
            </li>
             <li>
              <a href="img/Wood_and_Food.png">
                <img src="img/Wood_and_Food.png" alt="">
                <p>When Nature meets Food.</p>
              </a>
            </li>

             <li>
              <a href="img/basket.png">
                <img src="img/basket.png" alt="">
                <p>Patterned Designs with wood.</p>
              </a>
            </li>

             <li>
              <a href="img/firewood.png">
                <img src="img/firewood.png" alt="">
                <p>Firewood in Universal Circles.</p>
              </a>
            </li>




          </ul>
        </section>
        <footer>
          <a href="http://twitter.com/hilaryledoan">
          <img src="img/twitter-wrap.png" alt="Twitter Logo"
      class="social-icon"></a>

          <a href="http://facebook.com/hilary.ledoan">
            <img src="img/facebook-wrap.png" alt="Facebook Logo"
      class="social-icon"></a>
          <p>&copy; 2015 Hilary Ledoan.</p>
        </footer>
       </div>
      </body>
    </html>

CSS:

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



/*************************************
TWO COLUMN LAYOUT
*************************************/
#primary {
  width:300px;
  float: left;
  }
}

#secondary {
  width: 250px;
  float: right;
  margin-right: 20%;
  }
}

}

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

#gallery li {
  width: 28.333%;
}

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

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

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

}

/*************************************
HEADER
*************************************/
nav {
  background: none;
  float: right;
  font-size: 1.125em;
  margin-right: 5%;
  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 #757575;
  margin-bottom: 60px;
}

1 Answer

Jeff Jacobson-Swartfager
Jeff Jacobson-Swartfager
15,419 Points

The main issue was that you had a bunch of extra }. These were ending your @media queries earlier than you intended.

When you clean those up, the bottom border of the header and the placement of the navigation is as you expect it to be.

Check out this codepen to see what I mean (I've included the main.css at the top in order to get the base styles right).

hilary ledoan
hilary ledoan
3,533 Points

Thanks for the extra step! really appreciate it