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

Adam Maley
Adam Maley
5,946 Points

Need help with nav bar

The nav bar is all shifting to the right, creating a horizontal scroll and pushing out of the nav box. How do I fix this?

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="main.css">
<title>Halloween Hobby</title>
</head>

<body>
    <header class="header">
        <h1 class="logo"><img src="images/HalloweenHobbyLogo.svg" alt="Halloween Hobby Logo" width="15%" height="15%"></h1>
      <ul class="main-nav">
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Portfolio</a></li>
          <li><a href="#">Contact</a></li>
      </ul>
    </header> 


</body>

</html>
* {
    box-sizing: border-box;
}
body {
    font-family: 'Montserrat', sans-serif;
    line-height: 1.6;
    margin: 0;
    min-height: 100vh;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}


h2,
h3,
a {
    color: #34495e;
}

a {
    text-decoration: none;
}



.logo {
    margin: 0;
    font-size: 1.45em;
}

.main-nav {
    margin-top: 5px;

}
.logo a,
.main-nav a {
    padding: 10px 15px;
    text-transform: uppercase;
    text-align: center;
    display: block;
}

.main-nav a {
    color: #34495e;
    font-size: .99em;
}

.main-nav a:hover {
    color: #718daa;
}



.header {
    padding-top: .5em;
    padding-bottom: .5em;
    border: 1px solid #a2a2a2;
    background-color: #f4f4f4;
    -webkit-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
    -moz-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
    box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
}


/* ================================= 
  Media Queries
==================================== */




@media (min-width: 769px) {
    .header,
    .main-nav {
        display: flex;
    }
    .header {
        flex-direction: column;
        align-items: center;
        .header{
        width: 80%;
        margin: 0 auto;
        max-width: 1150px;
    }
    }

}

@media (min-width: 1025px) {
    .header {
        flex-direction: row;
        justify-content: space-between;
    }

}

1 Answer

Steven Parker
Steven Parker
231,096 Points

I can't seem to replicate the issue. Everything seems to behave (and not need a scrollbar) at all screen widths.

You could try using a workspace and then you could share the link to a snapshot that would include the images.