Im not entirely sure if its possible but I tried using a transition on my dropdown menu but it doesnt seem to work and i dont know why.
I've tried changing where I put the transition call but nothing seems to work. Its just a plain appear and disappear thing going on. Im trying to do this without using the @keyframes or any javascript rn and just pure CSS.
I need this to slide down as i hover over it.
function openNav() {
document.getElementById("sideNav").style.width = "400px";
document.getElementById("main").style.marginLeft = "400px";
//document.body.style.backgroundColor = "rgba(0,0,0,0.6)"
}
function closeNav() {
document.getElementById("sideNav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
document.body.style.backgroundColor = "#FFF";
}
.sideNav {
height: 100%;
width: 0;
/*Will change this part with js*/
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #3037af;
overflow-x: hidden;
padding-top: 150px;
transition: 0.5s;
border-bottom-right-radius: 80%;
border-top-right-radius: 80%;
}
.sideNav a {
padding: 20px;
display: block;
color: #f9f9f9;
text-decoration: none;
font-size: 32px;
opacity: 0.5;
transition: 0.3s;
font-family: 'Raleway', sans-serif;
transition-duration: 0.5s;
}
.sideNav a:hover {
opacity: 1;
font-size: 40px;
padding: 10px;
transition: 0.4s;
}
.dropdown {
overflow: hidden;
}
.dropdownContent {
display: none;
background-color: #2d347d;
position: relative;
padding: 10px;
border-bottom-right-radius: 80%;
border-top-right-radius: 80%;
z-index: 1;
}
.dropdownContent a {
left: 200px;
display: block;
transition: ease-in 0.3s;
transition-delay: 0.300ms;
}
.dropdown:hover .dropdownContent {
display: block;
}
<div class="mainContainer">
<div id="sideNav" class="sideNav">
<script src="js/main.js"></script>
<div class="dropdown">
<a href="#"><i class="fas fa-gifts"></i> Products</a>
<div class="dropdownContent">
<a href="#">Shop Now</a>
<a href="#">Store Locations</a>
</div>
</div>
</div>
</div>
<nav>
<button id="menu" onclick="openNav()" onfocusout="closeNav()"><i class="fas fa-bars"></i></button>
<div id="main">
<h1 class="landingHead">invision.</h1>
</div>
</nav>