概述

CSS animation-timing-function属性定义CSS动画在每一动画周期中执行的节奏。可能值为一或多个 <timing-function>

对于关键帧动画来说,timing function作用于一个关键帧周期而非整个动画周期,即从关键帧开始开始,到关键帧结束结束。

定义于一个关键帧区块的缓动函数(animation timing function)应用到改关键帧;另外,若该关键帧没有定义缓动函数,则使用定义于整个动画的缓动函数。

/* Keyword values */
animation-timing-function: ease;
animation-timing-function: ease-in;
animation-timing-function: ease-out;
animation-timing-function: ease-in-out;
animation-timing-function: linear;
animation-timing-function: step-start;
animation-timing-function: step-end;

/* Function values */
animation-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1);
animation-timing-function: steps(4, end);
animation-timing-function: frames(10);

/* Multiple animations */
animation-timing-function: ease, step-start, cubic-bezier(0.1, 0.7, 1.0, 0.1);

/* Global values */
animation-timing-function: inherit;
animation-timing-function: initial;
animation-timing-function: unset;

通常用animation简写定义整个动画属性更为方便。

初始值ease
适用元素all elements, ::before and ::after pseudo-elements
是否是继承属性
适用媒体visual
计算值as specified
Animation typediscrete
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

<timingfunction>
每个 <timing-function>代表了应用于动画的timing function,定义于animation-property.

正式语法

<single-timing-function>#

where
<single-timing-function> = linear | <cubic-bezier-timing-function> | <step-timing-function> | <frames-timing-function>

where
<cubic-bezier-timing-function> = ease | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>)
<step-timing-function> = step-start | step-end | steps(<integer>[, [ start | end ] ]?)
<frames-timing-function> = frames(<integer>)

示例

参见 CSS animations

规范

规范 状态 备注
CSS Animations
animation-timing-function
Working Draft  

浏览器兼容性

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes)-webkit
43.0
(Yes)-webkit
(Yes)
5.0 (5.0)-moz
16.0 (16.0)[1]
10 12 -o
12.10
4.0-webkit
frames() 未实现[2] ? 未实现[2] 未实现 未实现[2] ?
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support (Yes)-webkit (Yes)-webkit
(Yes)
5.0 (5.0)-moz
16.0 (16.0)[1]
? 12-o (Yes)-webkit ?
frames() ? ? 未实现[2] 未实现 (Yes) ? (Yes)

参见

文档标签和贡献者

 此页面的贡献者: zhuangyin, distums, mrstork, teoli, Sebastianz, fskuok
 最后编辑者: zhuangyin,