CSS旋转动画仅适用于Webkit

时间:2012-03-04 12:40:11

标签: css animation css3

我想让一个元素无限旋转360度。这是我的代码:

.rotate-animation {
  -webkit-animation: rotate 2s linear 0 infinite normal;
  -moz-animation: rotate 2s linear 0 infinite normal;
  -o-animation: rotate 2s linear 0 infinite normal;
  -ms-animation: rotate 2s linear 0 infinite normal;
  animation: rotate 2s linear 0 infinite normal;
}

@-webkit-keyframes rotate {
  from {
    -webkit-transform: rotate(0deg);

  }
  to { 
    -webkit-transform: rotate(360deg);
  }
}

@-moz-keyframes rotate {
  from {
    -moz-transform: rotate(0deg);

  }
  to { 
    -moz-transform: rotate(360deg);
  }
}

@-o-keyframes rotate {
  from {
    -o-transform: rotate(0deg);

  }
  to { 
    -o-transform: rotate(360deg);
  }
}

@-ms-keyframes rotate {
  from {
    -ms-transform: rotate(0deg);

  }
  to { 
    -ms-transform: rotate(360deg);
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);

  }
  to { 
    transform: rotate(360deg);
  }
}

它仅适用于Webkit浏览器。我做错了什么?

2 个答案:

答案 0 :(得分:5)

您还必须定义零0s秒。像这样:

-moz-animation: rotate 2s linear 0s infinite normal;

而不是这个

-moz-animation: rotate 2s linear 0 infinite normal;

选中此http://jsfiddle.net/srxzF/2/

答案 1 :(得分:0)

为了更安全,更好的选择是在所有情况下用 s 写秒数。

{{1}}