CSS3中对Animations和Transitions的比较

http://www.kirupa.com/html5/css3_animations_vs_transitions.htm


CSS3中的Animations和Transitions有些类似,但有点区别,举例如下:

Similarities


From a distance, both animations and transitions are very similar. They both allow you to:

  • Specify which CSS properties to listen for changes on
  • 设置一个CSS property作为修改对象
     
  • Set timing (easing) functions to alter the rate of going from a one property value to another
  • 设置时间函数来改变property的变化
     
  • Specify a duration to control how long the animation or transition will take
  • 设置总的延时
     
  • Programmatically listen to animation and transition-specific events that you can then do with as you wish
  • 设置监听
     
  • Visualize CSS property changes.
  • 可以直观的看到变化

Differences

Animations and transitions show their differences when it comes to how you trigger them to play, how complicated of a transition you can define, and how formal you must be in being able to use them. Let's explore those topics in greater detail.

Triggering

One of the major differences between animations and transitions can be seen in how you trigger them to start playing.

transition通常只能通过例如:hover的伪类来激活,或者动态加减class

animation则不需要任何东西就可以执行

Defining Intermediate Points / Keyframes


animation可以设置中间值,但是transition只能是开始和结尾值

Specifying Properties Up-Front


transtion必须对要改变的CSS property都设置上transtion:xxx,animation则比较松,之前的keyframe没有定义也没关系

Conclusion

如果你要做复杂的动画,使用animation,如果你只做简单的动画,使用transition

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值