目录

style animationTimingFunction 属性

示例

更改 <div> 元素的animationTimingFunction 属性:

document.getElementById("myDIV").style.animationTimingFunction = "linear";
亲自试一试 »

描述

AnimationTimingFunction指定动画的速度曲线。

速度曲线定义动画从一组 CSS 样式更改为另一组 CSS 样式所用的时间。

利用速度曲线使变化平滑。


语法

返回animationTimingFunction属性:

object.style.animationTimingFunction

设置animationTimingFunction属性:

object.style.animationTimingFunction = "linear|ease|ease-in|ease-out|cubic-bezier( n, n, n, n)|initial|inherit"

属性值

Value Description
linear The animation has the same speed from start to end
ease Default value. The animation has a slow start, then fast, before it ends slowly
ease-in The animation has a slow start
ease-out The animation has a slow end
ease-in-out The animation has both a slow start and a slow end
cubic-bezier(n, n, n, n) Define your own values in the cubic-bezier function
Possible values are numeric values from 0 to 1
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

技术细节

默认值: 舒适
返回值: 一个字符串,表示元素的动画计时功能属性
CSS版本 CSS3

浏览器支持

animationTimingFunction是 CSS3 (1999) 的一项功能。

所有浏览器都完全支持它:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 11

相关页面

CSS 参考:动画计时函数属性