【问题标题】:rotate in animation doesn't animate when the order of transform is not the same, why?当变换的顺序不同时,动画中的旋转不动画,为什么?
【发布时间】:2017-03-03 06:00:36
【问题描述】:

这是演示:http://codepen.io/anon/pen/WGLGyY

当关键帧为时,DIV 不旋转:

@keyframes test1{
    0% {
        transform: rotate(0) scale(1, 1)  translate(0,0)
    } 
    100% {
        transform:  scale(2, 2) rotate(180deg)  translate(200px,200px) 
    }
}

当我将关键帧更改为:

@keyframes test1{
    0% {
        transform: rotate(0) scale(1, 1)  translate(0,0)
    } 
    100% {
        transform:  rotate(360deg) scale(2, 2) translate(200px,200px) 
    }
}

它再次旋转。

那么这里的原因是什么?

我知道顺序可能会影响转换。

可能是因为 rotate(360deg) 等于 rotate(0);但是当我改变变换的顺序时,它又回来了....

【问题讨论】:

    标签: css html animation rotation frontend


    【解决方案1】:

    使用transform: none 作为您的第一个关键帧,它将旋转。

    它在行动:

    @keyframes test1{
    	0% {
    		transform: none;
    	}   
    	100% {
    		transform:  scale(2, 2) rotate(360deg)  translate(200px,200px) 
    	}
    }
    
    #test{
      width:200px;
      height: 200px;
      background: red;
      animation: test1 3s infinite
    }
    <div id="test"></div>

    【讨论】:

      猜你喜欢
      • 2018-02-28
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多