1. 程式人生 > >css實現動態旋轉

css實現動態旋轉

需求:重新整理按鈕點選後,動態旋轉

1.程式碼

.refresh-animation {
    animation: rotate 4s infinite;
    -webkit-animation: rotate 1s infinite; /*Safari and Chrome*/ 
}

@keyframes rotate {
    0%{
        transform:rotate(0deg);
        -ms-transform:rotate(0deg);     /* IE 9 */
        -moz-transform:rotate(0deg);    /* Firefox */
-o-transform:rotate(0deg); }
100% { transform:rotate(360deg); -ms-transform:rotate(360deg); /* IE 9 */ -moz-transform:rotate(360deg); /* Firefox */ -o-transform:rotate(360deg); } } @-webkit-keyframes rotate { 0%{ -moz-transform:rotate(0deg)
; }
100%{ -moz-transform:rotate(360deg); } }
$(this).addClass("refresh-animation");
$(this).removeClass("refresh-animation");

2.講解

[animation](http://www.w3school.com.cn/cssref/pr_animation.asp)
[transform](http://www.w3school.com.cn/cssref/pr_transform.asp)
注意animation的animation-name屬性(此例:rorate)必須與@keyframes ratote{}中的 ratote一致