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 Build a Responsive Navigation with Flexbox

Devon Deason
Devon Deason
7,061 Points

Main-content is all off?

While following along, my layout doesn't not preform the same a Guil's. I'm not sure what I'm doing wrong, perhaps a typo I've over looked?

<!DOCTYPE html>
<html>
<head>
    <title>Poly</title>
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/nav.css">
</head>
<body>

    <div class="container">

        <!-- start header   -->
        <header class="main-header">
            <a class="site-logo" href="#">
                <img src="img/logo.svg" alt="polu ui toolkit">
            </a>
            <ul class="nav">
            <li><a href="#">Typography</a></li>
            <li><a href="#">Graphs</a></li>
            <li><a href="#">Location</a></li>
            <li><a href="#">Support</a></li>
            <li><a href="#">Pictures</a></li>
            <li><a href="#">Website</a></li>
            </ul>
        </header>

        <!-- end header -->

        <div class="main-content">
            <h1>Main Headline</h1>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras mattis lobortis quam id venenatis. Integer eget pulvinar elit. Nunc magna mauris, sollicitudin eget ex quis, sagittis pretium velit. Morbi eget tortor vel massa iaculis tincidunt in eget nunc. Curabitur ornare faucibus fringilla. Praesent magna neque, auctor ac euismod sed, suscipit sed lorem. Curabitur euismod tellus et nibh condimentum mollis. Phasellus eleifend semper augue, ut feugiat orci fringilla non. Cras vel ultricies eros. Sed sed ante a ante gravida efficitur quis non dui. Fusce sagittis ullamcorper metus et tempus.</p>
        </div>
    </div>

</body>
</html>  
/* --------------------------
  Main Styles
--------------------------- */
.main-header,
.nav {
    display: flex;
    flex-direction: column;
}


.main-header {
    padding-top: 2em;
}

.site-logo {
    width: 110px;
    align-self: center
}

.nav {
    margin: 1.5em;
}

.nav a {
    display: block;
    color: #797e83;
    font-size: 1.125em;
    font-weight: 300;
    text-align: center;
    padding: .4em;
    border-bottom: 1px solid #ebecec;
}

.nav a:hover {
    color: #0b0b0b;
    border-bottom-color: #52bab3;
}





/* --------------------------
  Media Queries
--------------------------- */
@media (min-width: 769px) {
    .main-header {
        height: 200px;
    }
    .site-logo {
        width: 140px;
    }
    .nav {
        margin: 3em;
    }
    .nav a {
        border-bottom-color: transparent;
    }
}

Thanks for any help!

1 Answer

Hi Devon,

You were nearly there. You missed 2 small rules inside the media query.

Where you wrote:

.nav {
        margin: 3em;
    }

It should have been:

.nav {
      margin-top: 3em;
      flex-direction: row;
      justify-content: space-between;
    }
  • Elian