I tried to create a side menu bar with a sub-menu. The sub-menu should be visible when the cursor touches the main side menu. I used display: none;
and on hover I used display: block;
. The display: none;
is not working for the sub-menu.
I also tried visibility: hidden;
but it is also not working. What is wrong in my code?
.side-menu {
height: 89%;
width: 15%;
font-size: 18px;
font-family: Arial;
float: left;
z-index: 2;
}
.side-menu ul {
margin-left: 10px;
}
.side-menu ul li {
list-style-type: none;
font-weight: bold;
margin-top: 10px;
cursor: pointer;
}
.side-menu ul li:hover {
color: green;
}
.side-menu ul li ul {
display: none !important;
}
#side-menu ul li:hover ul {
display: block;
}
<html>
<head>
<title>Green Box</title>
</head>
<body>
<section class="header">
<div class="side-menu" id="side-menu">
<ul>
<li> Home</li><br>
<li>Offers<i class="fa fa-angle-right"></i></li>
<ul>
<li>sub menu</li>
<li>sub menu</li>
<li>sub menu</li>
<li>sub menu</li>
</ul>
<li>mega sale<i class="fa fa-angle-right"></i></li><br>
<li> great indian sale<i class="fa fa-angle-right"></i></li><br>
<li> glass</li><br>
<li>frames</li><br>
<li> gift</li><br>
</ul>
</div>
</section>
</body>
</html>