Looking to enhance the W3Schools menu with a multi-level dropdown? Check out the original W3Schools menu for reference here. I've attempted to create a multi-level dropdown as shown in these images:
Multi Level Dropdown Photo 1
Multi Level Dropdown Photo 2
The issue is that, as displayed in the photos, the multi-level dropdown does not close when you move to another level. Can this be fixed?
<div class="topnav" id="myTopnav">
<a href="#home" class="active"gt;Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
// More code here...
I have made some modifications, such as adding a sub-menu in order to achieve the desired multi-level functionality:
.topnav {
overflow: hidden;
background-color: #333;
}
// Styling properties and adjustments are mentioned here...
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
... Additional CSS code here ...
<div class="topnav" id="myTopnav">
<a href="#home" class="active">Home</a>
<a href="#news">News</a>
// More HTML content along with modifications...
<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a>
</div>