As the title suggests, I'm making a CSS dropdown menu.
My first problem was that when I hovered, the dropdown menu covered the hamburger icon. So I added margin-top which fixed that issue but caused another. When I would move my mouse off of the hamburger icon to select one of the drop down options, the dropdown menu would disappear. So my question is, how can I have a dropdown menu, which still displays the hamburger icon on display and lets me actually click the options without disappearing.
/* Global Styles */
* {
font-family: 'Open Sans', sans-serif;
}
a:link,
a:hover,
a:active,
a:visited {
text-decoration: none;
color: inherit;
}
/* Nav Bar Styling */
div.nav {
width: 100%;
background-color: #1c1c1c;
color: white;
position: absolute;
top: 0;
left: 0;
right: 0;
margin-top: 0;
height: 50px;
}
#title {
text-align: center;
vertical-align: middle;
margin: 0 auto;
font-size: 1.5em;
position: fixed;
top: 15px;
left: 50%;
right: 50%;
}
span.dropbutton {
text-align: left;
vertical-align: middle;
color: white;
position: fixed;
top: 15px;
left: 2%
}
#lines:hover {
transform: scale(1.1);
}
/* Dropdown Styling */
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #1c1c1c;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content a {
padding: 12px 16px;
display: block;
}
.dropdown-content a:hover {
background-color:
}
.dropdown:hover .dropdown-content {
display: block;
}
<div class="nav">
<span id="title">Title</span>
<div class="dropdown">
<span class="dropbutton">☰</span>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</div>