dd

animation-timing-function [播放方式]


语法

animation-timing-function: linear | ease | ease-in | ease-out | ease-in-out | step-start | step-end | steps(<number>[, [ start | end ] ]?) | cubic-bezier(<number>, <number>, <number>, <number>) [, linear | ease | ease-in | ease-out | ease-in-out | step-start | step-end | steps(<number>[, [ start | end ] ]?) | cubic-bezier(<number>, <number>, <number>, <number>) ]*; 指定对象动画的持续时间 。
语法项目说明
初始值ease
适用于所有元素
可否继承
媒介视觉
版本CSS3.0

说明

检索或设置对象动画的过渡类型

如果提供多个属性值,以逗号进行分隔。

取值

ease:缓解效果,等同于cubic-bezier(0.25,0.1,0.25,1.0)函数,既立方贝塞尔。

linear:线性效果,等同于cubic-bezier(0.0,0.0,1.0,1.0)函数。

ease-in:渐显效果,等同于cubic-bezier(0.42,0,1.0,1.0)函数。

ease-out:渐隐效果,等同于cubic-bezier(0,0,0.58,1.0)函数。

ease-in-out:渐显渐隐效果,等同于cubic-bezier(0.42,0,0.58,1.0)函数。

step-start:马上转跳到动画结束状态。

step-end:保持动画开始状态,直到动画执行时间结束,马上转跳到动画结束状态。

steps(<number>[, [ start | end ] ]?):第一个参数number为指定的间隔数,即把动画分为n步阶段性展示,第二个参数默认为end,设置最后一步的状态,start为结束时的状态,end为开始时的状态,若设置与animation-fill-mode的效果冲突,而以animation-fill-mode的设置为动画结束的状态。

cubic-bezier(<number>, <number>, <number>, <number>):特殊的立方贝塞尔曲线效果。

实例代码

CSS
.demo_box{
    -webkit-animation:f1 2s 0.5s forwards;
    -moz-animation:f1 2s 0.5s forwards;
    position:relative;
    left:10px;
    width:50px;
    height:50px;
    border-radius:50px;
    margin:10px 0;
    overflow:hidden;
}
.ease{ 
    -webkit-animation-timing-function:ease;
    -moz-animation-timing-function:ease;
}
.linear{
    -webkit-animation-timing-function:linear;
    -moz-animation-timing-function:linear;
}
.ease-in{
    -webkit-animation-timing-function:ease-in;
    -moz-animation-timing-function:ease-in;
}
.ease-out{
    -webkit-animation-timing-function:ease-out;
    -moz-animation-timing-function:ease-out;
}
.ease-in-out{
    -webkit-animation-timing-function:ease-in-out;
    -moz-animation-timing-function:ease-in-out;
}
.step-start{
    -webkit-animation-timing-function:step-start;
    -moz-animation-timing-function:step-start
}
.step-end{
    -webkit-animation-timing-function:step-end;
    -moz-animation-timing-function:step-end;
}
.steps{
    -webkit-animation-timing-function:steps(2);
    -moz-animation-timing-function:steps(2)
}
.cubic-bezier{
    -webkit-animation-timing-function:cubic-bezier(0.52,0,0.58,1.0);
    -moz-animation-timing-function:cubic-bezier(0.52,0,0.58,1.0);
}
@-webkit-keyframes f1{
    0%{left:10px;}
    100%{left:500px;}
}
@-moz-keyframes f1{
    0%{left:10px;}
    100%{left:500px;background:#f00}
}
HTML
<div class="demo_box ease">ease</div>
<div class="demo_box linear">linear</div>
<div class="demo_box ease-in">ease-in</div>
<div class="demo_box ease-out">ease-out</div>
<div class="demo_box ease-in-out">ease-in-out</div>
<div class="demo_box step-start">step-start</div>
<div class="demo_box step-end">step-end</div>
<div class="demo_box steps">steps(2)</div>
<div class="demo_box cubic-bezier">cubic-bezier(0.52,0,0.58,1.0)</div>
运行一下 »

兼容性

IEFirefoxOperaSafariChrome
IE 10+Firefox 3.5+目前暂无版本支持Safari 10+Chrome 2.0+