My issue involves a multi-level drop-down menu that is solely constructed using CSS. The problem I am facing is that there is a delay of one second before the drop-down closes when the mouse is moved away. This delay causes multiple drop-down menus to stack on top of each other when moving from one menu to another.
What I require is a solution where the drop-down closes immediately if the mouse hovers over another menu, preventing the accumulation of open drop-down menus. I am open to solutions utilizing jQuery as well.
You can find my current code in this jsfiddle and snippet provided below:
.main-navigation {
clear: both;
display: block;
float: left;
width: 100%;
}
.main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
}
.main-navigation ul ul {
visibility: hidden;
position: absolute;
top: 105%;
left: 0;
transition: 0s 0.5s;
z-index: 9999;
margin-top: -3px;
}
.main-navigation ul ul ul {
left: -999em;
top: 0;
}
.main-navigation ul ul li:hover>ul,
.main-navigation ul ul li.focus>ul {
left: 100%;
}
.main-navigation ul ul a {
width: 250px;
}
.main-navigation ul li:hover>ul,
.main-navigation ul li.focus>ul {
visibility: visible;
transition-delay: 0s;
z-index: 9999;
}
.main-navigation li {
float: left;
position: relative;
}
.main-navigation a {
display: block;
text-decoration: none;
}
.navigation li a,
.navigation li a:hover,
.navigation li.active a,
.navigation li.disabled {
color: #fff;
.navigation li {
background-color: #6FB7E9;
border-radius: 3px;
cursor: pointer;
padding: 12px;
padding: 0.75rem;
}
.navigation li a:hover,
.navigation li.active a {
background-color: #3C8DC5;
}
.sub-menu {
background-color: #419bd0;
border-top: 3px solid #2d6b90;
}
}
<nav class="main-navigation">
<div class="menu-main-nav-container">
<ul id="primary-menu" class="menu">
<li><a href="#">Parent</a>
<ul class="sub-menu">
<li><a href="#">Link Parent</a>
<ul class="sub-menu">
<li><a href="/">Link A</a></li>
<li><a href="/">Link A</a></li>
<li><a href="/">Link A</a></li>
<li><a href="/">Link A</a></li>
<li><a href="/">Link A</a></li>
<li><a href="/">Link A</a></li>
</ul>
</li>
<li><a href="#">Other</a>
<ul class="sub-menu">
<li><a href="/">Link B</a></li>
<li><a href="/">Link B</a></li>
<li><a href="/">Link B</a></li>
<li><a href="/">Link B</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</nav>