浏览器支持 :
Internet Explorer 10、Firefox 以及 Opera 支持 animation 属性;
Safari 和 Chrome 支持替代的 -webkit-animation 属性。
定义和用法
animation 属性是一个简写属性,用于设置六个动画属性:
animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction语法
animation: name duration timing-function delay iteration-count direction;值 描述 animation-name 规定需要绑定到选择器的 keyframe 名称。。
animation-name: keyframename|none;animation-duration
规定完成动画所花费的时间,以秒或毫秒计。
animation-duration: time;animation-timing-function 规定动画的速度曲线。
animation-timing-function: value;animation-delay
规定在动画开始之前的延迟。
animation-delay: time;animation-iteration-count 规定动画应该播放的次数。
animation-iteration-count: n|infinite(无限次);animation-direction 规定是否应该轮流反向播放动画。
animation-direction: normal(正常)|alternate(轮流反向播放);
其中
animation-timing-function 使用名为三次贝塞尔(Cubic Bezier)函数的数学函数,来生成速度曲线。您能够在该函数中使用自己的值,也可以预定义的值:
值 描述 linear 动画从头到尾的速度是相同的。 ease 默认。动画以低速开始,然后加快,在结束前变慢。 ease-in 动画以低速开始。 ease-out 动画以低速结束。 ease-in-out 动画以低速开始和结束。 cubic-bezier(n,n,n,n) 在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值。
案例:
很实际的,一个箭头循环上下跳动
#auto{
-webkit-animation:dd 1s infinite;
animation:dd 1s infinite;
}
@keyframes dd{
0% {transform:translate(0, 10px)}
50% {transform:translate(0, 0)}
100% {transform:translate(0, 10px)}
}
@-webkit-keyframes dd{
0% {-webkit-transform:translate(0, 10px)}
50% {-webkit-transform:translate(0, 0)}
100% {-webkit-transform:translate(0, 10px)}
}
注释:animation 这个属性的使用必须结合@keyframes一起使用
百分比的意思就是duration的百分比,如果没有设置duration的话,则表示为无穷大。
transform:translate():含义--变动,位移;也是CSS3里面的新属性。
查看更多关于CSS3学习之animation属性_html/css_WEB-ITnose的详细内容...