Currently, I am in the process of developing a website that features a dropdown menu.
I would like it so that when you click on the menu, it appears, but if you move your cursor away from it, it disappears until you click on it again.
Below is the HTML snippet I have for this feature (please note that the links are placeholders and the dropdown menu is only available on the main page at this time):
<div class='dropdown-project' id="project">
<a class='dropbtn-project' href='#project'>Projects</a>
<div class='dropcontent-project'>
<a href="#">Project1</a>
<a href="#">Project2</a>
</div>
</div>
and here is the corresponding CSS code:
.dropbtn-project {
padding: 16px;
border: none;
}
.dropdown-project {
position: relative;
display: inline-block;
}
.dropcontent-project {
display: none;
position: absolute;
background-color: var(--main-header-background);
min-width: 150px;
z-index: 1;
}
.dropcontent-project a {
padding: 5px 10px;
display: block;
}
.dropcontent-project a:hover {
color: var(--hover-fonts-color);
background: var(--main-decor-color)
}
.dropdown-project:target .dropcontent-project {display: block;}
.dropdown-project:hover .dropbtn-project {background-color: var(--main-decor-color);}
.dropdown-project:not(:hover) .dropcontent-project {display: none;}
However, I am facing an issue where the target remains active after a single click, causing the menu to reappear on hover after the initial click.
If you would like to view this feature, please visit .
(Kindly note that the text on the website is primarily in German, so "Projekte" translates to "projects" and "Projekt" translates to "project")