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