Код: Выделить всё
document.querySelector('#button1').onclick = ({ currentTarget }) => {
currentTarget.style.animation = 'mymove 2s linear forwards';
}
document.querySelector('#button2').onclick = ({ currentTarget }) => {
currentTarget.style.animation = 'mymove 2s linear reverse backwards';
}< /code>
#button1,
#button2 {
width: 100px;
height: 100px;
background: red;
position: relative;
}
#button2 {
background: aqua;
}
@keyframes mymove {
from {top: 0px;}
to {top: 200px;}
}< /code>
Подробнее здесь: https://stackoverflow.com/questions/644 ... d-abruptly