I am creating a mock site for a class. I want to one of the navigation items to have a dropdown menu. However, I’m running into issues with the positioning of the dropdown menu.
Its default position is right against the navigation item, but I want there to be just a little bit of space between the two. However, when I add margin-top to container of the dropdown content, then the dropdown content can no longer be scrolled. I know the reason for this — the extra space prevents the content from being scroll-able — but I don’t know how to fix it.
.nav-items li {
list-style-type: none;
display: inline;
}
.dropdown li {
list-style-type: none;
display: block;
}
.services {
position: relative;
}
.services-list {
position: absolute;
display: none;
background-color: #f1f1ed;
border: 1px solid black;
top: 100%;
}
#services a {
text-decoration: none;
color: black;
}
#services:hover .services-list {
display: block;
position: absolute;
}
<ul class="nav-items">
<li>About</li>
<li id="services"><a href="#">Services</a>
<div class="services dropdown">
<ul class="services-list">
<li>Advocacy</li>
<li>Brochures</li>
<li>Speaker program</li>
<li>Helpline</li>
</ul>
</div>
</li>
<li>TransPages</li>
<li>Events</li>
<li>Our Supporters</li>
<li>Get Involved</li>
<li>Contact</li>
2
Answers
I hope this updated css resolves your issue. Also I commented out your styles that were not necessary.
You can use this html and css
HTML
CSS