css 代碼:
/* 刷新按鈕 */
.refresh {
width: 32px;
height: 32px;
position: relative;
top: -2px;
}
/* 刷新動畫 */
@-webkit-keyframes rotation {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@keyframes rotation {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg)
}
to {
-webkit-transform: rotate(360deg);
transform: rotate(360deg)
}
}
html 代碼:
<img class="refresh" src="./img/refresh.png" alt="">
js 代碼:
$(".refresh").on('click', function () {
$(this).css("-webkit-animation", "rotation 1s ease-out 1");
$(this).css("-ms-animation", "rotation 1s ease-out 1");
$(this).css("animation", "rotation 1s ease-out 1");
var z = $(this);
setTimeout(function () {
$(z).css("animation", "");
}, 1000);
});