Struggling to figure out how to open my dropdown sub-menu using CSS. Hoping to make it so the user can open it by hovering over the corresponding tag. I attempted to use #lablinksDD
to trigger the opening of #ddSbMenu
when hovered over #menuDD
with #labLinksDD:hover #ddSbMenu
. What am I missing here?
Code:
HTML
<ul>
<li><a href="DD/Index.html" class="tpNavBtns">Digital Design (DD) ▾</a></li> <!--▴-->
<ul class="subMenu1" id="menuDD">
<li><a href="#" id="labLinksDD">Labs ▸</a></li> <!--◂-->
<ul class="drpDn-subMenu labSbMenu" id="ddSbMenu">
<li><a href="DD/Labs/Lab_01/LB1_WeiJianZhen_DD.html">DD Lab 1</a></li>
<li><a href="DD/Labs/Lab_02/LB2_WeiJianZhen_DD.html">DD Lab 2</a></li>
<li><a href="DD/Labs/Lab_03/Lab_3.html">DD Lab 3</a></li>
<!--more than 20 a tags inside lists-->
</ul>
CSS
.drpDn-subMenu {
display: none;
position: absolute;
width: 200px;
height: 500px;
top: 0px;
left: 164px;
overflow-x: hidden;
overflow-y: scroll;
background-color: red;
list-style-type: none;
border-left: 1px solid rgba(120, 120, 120, 0.70);
border-bottom: 1px solid rgba(120, 120, 120, 0.70);
}
.drpDn-subMenu a {
display: inline-block;
position: relative;
padding: 20px 50px;
width: 100%;
height: auto;
text-align: left;
}
#menuDD {
top: 100%;
left: 13.6%;
}
#menuWCP {
top: 50px;
left: 800px;
}
.labSbMenu {
z-index: 3;
}
.prSbMenu {
top: 56px;
height: auto;
background-color: antiquewhite;
}
If you have an alternative Vanilla JavaScript solution rather than a CSS one, feel free to share!