How to control css3 animation rotate direction

hh54188 picture hh54188 · May 6, 2012 · Viewed 9.1k times · Source

I want rotate a element with css3 animation and transform property,which from 20 degree to -20 degree

@-moz-keyframes oneRotate{
    0%{
        -moz-transform: rotate(20deg);
    }
    100%{
        -moz-transform:rotate(-20deg);
    }
}

.oneRotate
{
    -moz-transform-style: preserve-3d;

   -moz-animation-name:oneRotate;
   -moz-animation-duration:2s;
   -moz-animation-timing-function:ease-in-out;
   -moz-animation-delay:0s;
   -moz-animation-iteration-count:infinite;
   -moz-animation-direction:normal;
}

the rotate order is 20 -> 0 -> -20... is anti-clockwise

but I want the order is 20 -> 90 -> 180 -> ...is clockwise

what can I do to achieve that?

Answer

Venge picture Venge · May 6, 2012

Set the 100% rotation angle to 340 degrees. It's the same angle as -20 degrees since -20 + 360 = 340, but it'll rotate in the opposite direction since 340 > 20 but -20 < 20.