26
2016
07

CSS3 animation 属性

使用简写属性,将动画与 div 元素绑定:

div
{
animation:mymove 5s infinite;
-webkit-animation:mymove 5s infinite; /* Safari 和 Chrome */
}

语法

animation: name duration timing-function delay iteration-count direction;


描述
animation-name规定需要绑定到选择器的 keyframe 名称。。
animation-duration规定完成动画所花费的时间,以秒或毫秒计。
animation-timing-function规定动画的速度曲线。
animation-delay规定在动画开始之前的延迟。
animation-iteration-count规定动画应该播放的次数。
animation-direction规定是否应该轮流反向播放动画。



CSS3 animation-duration 属性

为 @keyframes 动画规定一个名称:

div
{
animation-duration:2s;
-webkit-animation-duration:2s; /* Safari 和 Chrome */
}

语法:

animation-duration: time;


CSS3 animation-timing-function 属性

从开头到结尾以相同的速度来播放动画:

div
{
animation-timing-function:2s;
-webkit-animation-timing-function:2s; /* Safari 和 Chrome */}

语法:

animation-timing-function: value;

animation-timing-function 使用名为三次贝塞尔(Cubic Bezier)函数的数学函数,来生成速度曲线。您能够在该函数中使用自己的值,也可以预定义的值:

描述
linear动画从头到尾的速度是相同的。
ease默认。动画以低速开始,然后加快,在结束前变慢。
ease-in动画以低速开始。
ease-out动画以低速结束。
ease-in-out动画以低速开始和结束。
cubic-bezier(n,n,n,n)在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值。


CSS3 animation-delay 属性

等待两秒,然后开始动画:

div
{
animation-delay:2s;
-webkit-animation-delay:2s; /* Safari 和 Chrome */}

语法:

animation-delay: time;
描述
time可选。定义动画开始前等待的时间,以秒或毫秒计。默认值是 0。


CSS3 animation-iteration-count 属性

播放动画三次:

div
{
animation-iteration-count:3;
-webkit-animation-iteration-count:3; /* Safari 和 Chrome */}

语法:

animation-iteration-count: n|infinite;
描述
n定义动画播放次数的数值。
infinite规定动画应该无限次播放。


CSS3 animation-direction 属性

暂停动画:

div
{
animation-direction:alternate;
-webkit-animation-direction:alternate; /* Safari 和 Chrome */}

语法:

animation-direction: normal|alternate;
描述
normal默认值。动画应该正常播放。
alternate动画应该轮流反向播放。


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。