I cant figure out how to keep the unordered list items from extending too far to the right in the viewport. I have tried using width: 100%; for a responsive layout but with no luck. I'm starting to think it has to do with the display: selector.
The layout is fine 769px and above.
navigation bar extending too far to the right
.drop-navbar {
background: rgb(49, 1, 70);
text-align: center;
border-bottom: solid white 2px;
height: auto;
padding: 0px;
width: 100%;
}
.drop-navbar ul {
display: inline-flex;
list-style: none;
color: aliceblue;
}
.drop-navbar ul li {
margin: 0 auto;
padding: 10px;
}
.drop-navbar ul li a {
text-decoration: none;
color: aliceblue;
}
.drop-link {
display: none;
}
.drop-navbar ul li:hover .drop-link {
display: block;
position: absolute;
background: rgb(49, 1, 70);
margin-top: 5px;
margin-left: -5px;
}
.drop-navbar ul li:hover {
background: rgb(153, 0, 255);
border-radius: 3px;
}
.drop-navbar ul li:hover .drop-link ul {
display: block;
margin: 10px;
}
.drop-navbar ul li:hover .drop-link ul li {
width: 125px;
padding: 10px;
border-bottom: 1px solid #fff;
background: transparent;
border-radius: 0;
text-align: left;
}
.drop-navbar ul li:hover .drop-link ul li:last-child {
border-bottom: none;
}
.drop-navbar ul li:hover .drop-link ul li a:hover {
color: rgb(153, 0, 255);
}
<div class="site-container">
<nav class="drop-navbar">
<img class="navbarbg" src="resources/css/jessiemeesphotos/navbarbg.png">
<strong>
<ul>
<li><a href="about.html">About</a></li>
<li>
<a href="#">For Sale</a>
<div class="drop-link">
<ul>
<li><a href="for_sale.html">Earrings</a></li>
<li><a href="for_sale.html">Necklaces</a></li>
<li><a href="for_sale.html">Rings</a></li>
<li><a href="for_sale.html">Bracelets</a></li>
</ul>
</div>
</li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</strong>
</nav>
</div>
Remove the padding from your <ul>
element to center the items.
.drop-navbar ul {
padding: 0;
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
}