I am struggling with the stack order of my dropdown menu. Despite using z-index, it appears in front of the button instead of behind it. I want it to look like it is coming out from behind the button. Here is my code:
.subnav-wrapper {
position: relative;
padding: 10px 15px !important;
cursor: pointer;
z-index: 0;
}
.subnav-wrapper:hover .subnav {
visibility: visible;
transition-delay: 0s, 0s, 0.05s;
transform: translateY(0%);
z-index: 1;
}
.subnav-wrapper:hover .subnav a {
opacity: 1;
}
.subnav {
position: absolute;
padding: inherit;
background-color: black;
color: white;
z-index: -1;
min-width: 110px;
visibility: hidden;
margin-top: 10px;
transform: translateY(-100%);
transition: ease-in-out 0s, visibility 0.05s linear 0.3s, z-index 0.3s linear 0.01s, transform 0.14s;
}
.subnav a {
opacity: 0;
transition: opacity 0.3s;
}
a {
text-decoration: none;
}
.black-text {
color: black;
}
.subnav-element {
color: white;
display: inline-block;
padding: 5px 5px;
font-size: 0.9em;
}
<div class="nav-element subnav-wrapper"><a class="black-text" href="#">ABOUT</a>
<div class="subnav">
<a class="subnav-element" href="#">WHO WE ARE</a>
<a class="subnav-element" href="#">PROJECTS</a>
<a class="subnav-element" href="#">PARTNERS</a>
<a class="subnav-element" href="#">CONTACT</a>
</div>
</div>