I'm encountering an issue with my submenu. It's supposed to appear when hovering over the parent menu li
, but it also shows up when the mouse hovers over its area. Let's take a look at some images.
First screenshot below shows that it works properly: https://i.stack.imgur.com/3Xn6T.png
Second screenshot below shows the submenu appearing when hovering over a list item in the submenu:
https://i.stack.imgur.com/de3nZ.png
Now let's review the HTML code:
<nav class="header-navigation">
<ul>
<li><a href="">Home</a></li>
<li>
<a href="">Blog Styles</a>
<ul>
<li><a href="">Image Post</a></li>
<li><a href="">Audio Post</a></li>
</ul>
</li>
<li>
<a href="">Level 1</a>
</li>
</ul>
</nav>
And here is the CSS:
nav.header-navigation ul > li > ul{
background: #fff;
box-shadow: 0px 2px 15px rgba(0,0,0,0.1);
position: absolute;
z-index: 999;
width: auto;
top: 21px;
white-space: nowrap;
padding: 15px 17px 13px;
margin-top: 18px;
left: 0;
visibility: hidden;
opacity: 0;
transform: translateY(10px);
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
-ms-transform: translateY(10px);
-o-transform: translateY(10px);
transition: all .3s ease;
-moz-transition: all .3s ease;
-webkit-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
}
nav.header-navigation > ul > li:hover > ul{
visibility: visible;
opacity: 1;
transform: rotate(0deg) translateY(0px);
-webkit-transform: rotate(0deg) translateY(0px);
-moz-transform: rotate(0deg) translateY(0px);
-ms-transform: rotate(0deg) translateY(0px);
-o-transform: rotate(0deg) translateY(0px);
}
nav.header-navigation > ul > li > ul > li:hover > ul{
visibility: visible;
opacity: 1;
transform: rotate(0deg) translateY(0px);
-webkit-transform: rotate(0deg) translateY(0px);
-moz-transform: rotate(0deg) translateY(0px);
-ms-transform: rotate(0deg) translateY(0px);
-o-transform: rotate(0deg) translateY(0px);
}