【问题标题】:What transition-property to use for transform?用于转换的过渡属性是什么?
【发布时间】:2012-06-05 14:29:22
【问题描述】:

我不确定这是否正确,但我想旋转一个元素,
我知道transform: rotate(90deg)transition-property:all 会起作用,但我不想转换all 的转换
。 我应该使用什么transition-property,有没有更好的方法来创建旋转动画?

【问题讨论】:

标签: css css-transforms


【解决方案1】:

要在transition-property 上定位transforms,您应该使用:

-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-ms-transition-property: -ms-transform;
-o-transition-property: -o-transform;
transition-property: transform;

【讨论】:

  • 我认为 IE 永远不会在头部转换前缀,不是吗?
【解决方案2】:

也许不是更好的方法,但您也可以使用动画关键帧(如果您想连续重复动画效果更好):

@keyframes rotateDiv {
   from { transform: rotateZ(0deg); }
   to   { transform: rotateZ(360deg); }
}

div {
   animation-name: rotateDiv;
   animation-duration: 1s;
   animation-timing-function: linear; /* For a steady rate loop */
   animation-delay: 0s;            
   animation-iteration-count: infinite; /* Use actual numbers for limited repeat */
}

【讨论】:

    猜你喜欢
    • 2022-08-19
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多