js 点击刷新的按钮执行动画 (转一圈)


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);
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM