css 代码:
/* 刷新按钮 */
.refresh {
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);
});