i have set animation in property on HTML element when it is displayed, i want same animation on reverse, when button is clicked it should hide with same animation.
how can i achieve that.
"Animation in" which is working:
.modal{
animation: myAnim 1s ease 0s 1 normal forwards;
}
@keyframes myAnim {
0% {
opacity: 0;
transform: translateX(-50px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
HTML:
<div id="myModal" class="modal fixed hidden z-1 w-full h-full bg-red-100 h-screen ">
<button id="myBtn" class=" p-2 bg-yellow-400 rounded m-4 absolute right-0 text-xs font-bold ">
HIDE/SHOW..
</button>
i am showing/hidding modal using JS. how can i hide modal with same animation.