Trying to make a drop down on a nav like this:
Here's the HTML and CSS - it just stays to the left of the nav links
Here’s what it’s doing:
Whenever I hover over the links (housing, cleaning etc), the drop-down sticks to the left of the navigation links, and doesn't actually "drop down" below the original headings. How can this be fixed?
Here's the HTML and CSS - it just stays to the left of the nav links
HTML:
<header>
<img src="logo.png" alt="" class="logo">
<nav class="right">
<ul class="nav-links">
<li><a href="#">Home</a></li>
<li><a href="#">Food</a></li>
<ul>
*4 <li> items*
</ul>
<li><a href="#">Housing</a></li>
<ul>
*4 <li> items*
</ul>
<li><a href="#">Cleaning</a></li>
<ul>
*4 <li> items*
</ul>
<li><a href="#">Decor</a></li>
<ul>
*4 <li> items*
</ul>
</ul>
</nav>
</header>
CSS:
header, ul, a{
display: flex;
justify-content: space-between;
align-items: center;
background-color: #6B8E23;
list-style: none;
text-decoration: none;
color: white;
padding-right: 50px;
font-weight: 600;
}
header{
display: flex;
justify-content: space-between;
align-items: center;
}
.right a{
padding: 0 20px 0 20px;
border-right: 2px solid white;
font-size: large;
}
.right > a:last-of-type{
border-right: none;
}
.nav.links a:hover{
background-color: #000;
}
.nav-links ul {
display: none;
position: absolute;
}
.nav-links:hover > ul{
display: block;
border: none;
}
Here’s what it’s doing:
Whenever I hover over the links (housing, cleaning etc), the drop-down sticks to the left of the navigation links, and doesn't actually "drop down" below the original headings. How can this be fixed?