Answer the question
In order to leave comments, you need to log in
How to make an animation when minimizing a modal with CSS?
There is an example of how to create a modal window with animation:
https://www.w3schools.com/howto/howto_css_modal_im...
Here the animation works only when the window is opened. How can I make it work when closed? I tried to do like this:
.animation-open {
-webkit-animation-name: zoom-in;
-webkit-animation-duration: 0.6s;
animation-name: zoom-in;
animation-duration: 0.6s;
}
.animation-close{
-webkit-animation-name: zoom-out;
-webkit-animation-duration: 0.6s;
animation-name: zoom-out;
animation-duration: 0.6s;}
@-webkit-keyframes zoom-in {
from {-webkit-transform:scale(0)}
to {-webkit-transform:scale(1)}
}
@keyframes zoom-in {
from {transform:scale(0)}
to {transform:scale(1)}
}
@-webkit-keyframes zoom-out {
from {-webkit-transform:scale(1)}
to {-webkit-transform:scale(0)}
}
@keyframes zoom-out {
from {transform:scale(1)}
to {transform:scale(0)}
}
img.onclick = function(){
modal.classList.remove("animation-close");
modal.style.display = "block";
modalImg.src = this.src;
captionText.innerHTML = this.alt;
modalImg.classList.toggle("animation-open");
}
var span = document.getElementsByClassName("close")[0];
span.onclick = function() {
modal.classList.toggle("animation-close");
//здесь должна быть задержка
modal.style.display = "none";
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question