--- title: transition-timing-function slug: Web/CSS/transition-timing-function translation_of: Web/CSS/transition-timing-function ---

{{ CSSRef() }}{{SeeCompatTable}}

概述

CSS属性受到 transition effect的影响,会产生不断变化的中间值,而 CSS transition-timing-function 属性用来描述这个中间值是怎样计算的。实质上,通过这个函数会建立一条加速度曲线,因此在整个transition变化过程中,变化速度可以不断改变。

这条加速度曲线被{{cssxref("<timing-function>")}}所定义,之后作用到每个CSS属性的过渡. 

你可以规定多个timing function,通过使用 {{ cssxref("transition-property") }}属性,可以根据主列表(transition property的列表)给每个CSS属性应用相应的timing function.如果timing function的个数比主列表中数量少,缺少的值被设置为初始值(ease) 。如果timing function比主列表要多,timing function函数列表会被截断至合适的大小。这两种情况下声明的CSS属性都是有效的。

{{cssinfo}}

语法

Formal syntax: {{csssyntax("transition-timing-function")}}
transition-timing-function: ease
transition-timing-function: ease-in
transition-timing-function: ease-out
transition-timing-function: ease-in-out
transition-timing-function: linear
transition-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1)
transition-timing-function: step-start
transition-timing-function: step-end
transition-timing-function: steps(4, end)

transition-timing-function: ease, step-start, cubic-bezier(0.1, 0.7, 1.0, 0.1)

transition-timing-function: inherit

<timing-function>
通过{{ cssxref("transition-property") }}中定义被过渡属性,每个 {{cssxref("<timing-function>")}}的值代表与这个属性相对应的timing function.

示例

transition-timing-function: ease

{{EmbedLiveSample("ttf_ease",275,150)}}

transition-timing-function: ease-in

{{EmbedLiveSample("ttf_easein",275,150)}}

transition-timing-function: ease-out

{{EmbedLiveSample("ttf_easeout",275,150)}}

transition-timing-function: ease-in-out

{{EmbedLiveSample("ttf_easeinout",275,150)}}

transition-timing-function: linear

{{EmbedLiveSample("ttf_linear",275,150)}}

transition-timing-function: step-start

{{EmbedLiveSample("ttf_stepstart",275,150)}}

transition-timing-function: step-end

{{EmbedLiveSample("ttf_stepend",275,150)}}

transition-timing-function: steps(4, end)

{{EmbedLiveSample("ttf_step4end",275,150)}}

规范

Specification Status Comment
{{ SpecName('CSS3 Transitions', '#transition-timing-function', 'transition-timing-function') }} {{ Spec2('CSS3 Transitions') }}  

浏览器兼容性

{{Compat("css.properties.transition-timing-function")}}

参考