I set a div of a dropdown to have an animation as below and this happens when div opens up:
.locationDropdownList {
position: absolute;
top: 83px;
width: 100%;
background: white;
z-index: 1000;
padding: 0 1rem 1rem 1rem;
animation: dropdown 250ms ease-in-out;
box-shadow: 0px 30px 25px 0px rgba(0, 0, 0, 0.2);
max-height: 250px;
overflow-x: hidden;
}
@keyframes dropdown {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
It works when it opens but how can I also set it when it is closing? I tried adding 0% underneath 100% but that didn't do anything. Any suggestions on this?
Update:
So how it works is like below
I have a parent of the div called LocationDropdown
and when that is clicked, a class called focused
is applied to the parent which then activates the dropdown to open locationDropdownList
which is a div that holds the list
<div class="LocationDropdown">
<div>
<p class="locationSelectText">London</p>
</div>
</div>
when clicked focused class is applied
<div class="LocationDropdown focused">
<div>
<p class="locationSelectText">London</p>
</div>
<div class="locationDropdownList">
<ul>
<li></li>
.....
.....
</ul>
<ul>
<li></li>
.....
.....
</ul>
<ul>
<li></li>
.....
.....
</ul>
</div>
</div>