2
當複選框被選中時,div
正在跳躍。當您取消選中複選框時,div
會立即移至初始位置。平滑動畫停止
是否可以順利地完成最後一個動畫迭代,並且在僅使用沒有JS的CSS之後停止?
#jumping-div {
width: 100px;
height: 100px;
margin-top: 100px;
background-color: red;
}
@keyframes jump {
0% {
transform: scaleY(1) translateY(0);
}
50% {
transform: scaleY(0.8) translateY(-70%);
}
}
#toggle:checked ~ #jumping-div {
animation-name: jump;
animation-duration: 2.0s;
animation-iteration-count: infinite;
}
<input type="checkbox" id="toggle"><label for="toggle">jump</label>
<div id="jumping-div"></div>