animation-timing-function CSS property sets how an animation progresses through the duration of each cycle.

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

It is often convenient to use the shorthand property animation to set all animation properties at once.

句法

/* 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);
/* Steps Function keywords */
animation-timing-function: steps(4, jump-start);
animation-timing-function: steps(10, jump-end);
animation-timing-function: steps(20, jump-none);
animation-timing-function: steps(5, jump-both);
animation-timing-function: steps(6, start);
animation-timing-function: steps(8, end);
/* 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;
				

Timing functions may be specified on individual keyframes in a @keyframes rule. If no animation-timing-function is specified on a keyframe, the corresponding value of animation-timing-function from the element to which the animation is applied is used for that keyframe.

A keyframe's timing function is applied on a property-by-property basis from the keyframe on which it is specified until the next keyframe specifying that property, or until the end of the animation if there is no subsequent keyframe specifying that property. As a result, an animation-timing-function specified on the 100% or to keyframe will never be used.

<timing-function>

The timing function that corresponds to a given animation, as determined by animation-name .

The non-step keyword values (ease, linear, ease-in-out, etc.) each represent cubic Bézier curve with fixed four point values, with the cubic-bezier() function value allowing for a non-predefined value. The step timing functions divides the input time into a specified number of intervals that are equal in length. It is defined by a number of steps and a step position.

ease
Equal to cubic-bezier(0.25, 0.1, 0.25, 1.0) , the default value, increases in velocity towards the middle of the animation, slowing back down at the end.
linear
Equal to cubic-bezier(0.0, 0.0, 1.0, 1.0) , animates at an even speed.
ease-in
Equal to cubic-bezier(0.42, 0, 1.0, 1.0) , starts off slowly, with the speed of the transition of the animating properting increasing until complete.
ease-out
Equal to cubic-bezier(0, 0, 0.58, 1.0) , starts quickly, slowing down the animation continues. •
ease-in-out
Equal to cubic-bezier(0.42, 0, 0.58, 1.0) , with the animating properties slowly transitioning, speeding up, and then slowing down again.
cubic-bezier(p1, p2, p3, p4)

An author defined cubic-bezier curve, where the p1 and p3 values must be in the range of 0 to 1.

steps(n, <jumpterm>)
Displays an animation iteration along n stops along the transition, displaying each stop for equal lengths of time. For example, if n is 5, there are 5 steps. Whether the animation holds temporarily at 0%, 20%, 40%, 60% and 80%, on the 20%, 40%, 60%, 80% and 100%, or makes 5 stops between the 0% and 100% along the animation, or makes 5 stops including the 0% and 100% marks (on the 0%, 25%, 50%, 75%, and 100%) depends on which of the following jump terms is used:
jump-start

Denotes a left-continuous function, so that the first jump happens when the animation begins;

jump-end

Denotes a right-continuous function, so that the last jump happens when the animation ends;

jump-none

There is no jump on either end. Instead, holding at both the 0% mark and the 100% mark, each for 1/n of the duration.

jump-both

Includes pauses at both the 0% and 100% marks, effectively adding a step during the animation iteration.

start
如同 jump-start .
end
如同 jump-end .
step-start
Equal to steps(1, jump-start)
step-end
Equal to steps(1, jump-end)

注意 : When you specify multiple comma-separated values on an animation-* property, they will be assigned to the animations specified in the animation-name property in different ways depending on how many there are. For more information, see Setting multiple animation property values .

形式定义

初始值 ease
适用于 所有元素, ::before and ::after pseudo-elements
继承 no
计算值 如指定
动画类型 discrete

形式句法

<timing-function>#

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

where
<cubic-bezier-timing-function> = ease | ease-in | ease-out | ease-in-out | cubic-bezier(<number <a href="/en-US/docs/CSS/Value_definition_syntax#Brackets" title="Brackets: enclose several entities, combinators, and multipliers to transform them as a single component">[0,1]>, <number>, <number <a href="/en-US/docs/CSS/Value_definition_syntax#Brackets" title="Brackets: enclose several entities, combinators, and multipliers to transform them as a single component">[0,1]>, <number>)
<step-timing-function> = step-start | step-end | steps(<integer>[, <step-position>]?)

where
<step-position> = jump-start | jump-end | jump-none | jump-both | start | end

范例

Cubic-Bezier examples

<div class="parent">
  <div class="ease">ease</div>
  <div class="easein">ease-in</div>
  <div class="easeout">ease-out</div>
  <div class="easeinout">ease-in-out</div>
  <div class="linear">linear</div>
  <div class="cb">cubic-bezier(0.2,-2,0.8,2)</div>
</div>
							
.parent > div[class] {
    animation-name: changeme;
    animation-duration: 10s;
    animation-iteration-count: infinite;
    margin-bottom: 4px;
}
@keyframes changeme {
   0% {
      min-width: 12em;
      width: 12em;
      background-color: black;
      border: 1px solid red;
      color: white;
   }
   100% {
      width: 90vw;
      min-width: 24em;
      background-color: magenta;
      color: yellow;
      border: 1px solid orange;
   }
}
							
.ease {
   animation-timing-function: ease;
}
.easein {
   animation-timing-function: ease-in;
}
.easeout {
   animation-timing-function: ease-out;
}
.easeinout {
   animation-timing-function: ease-in-out;
}
.linear {
   animation-timing-function: linear;
}
.cb {
   animation-timing-function: cubic-bezier(0.2,-2,0.8,2);
}
							

Step examples

<div class="parent">
  <div class="jump-start">jump-start</div>
  <div class="jump-end">jump-end</div>
  <div class="jump-both">jump-both</div>
  <div class="jump-none">jump-none</div>
  <div class="start">start</div>
  <div class="end">end</div>
  <div class="step-start">step-start</div>
  <div class="step-end">step-end</div>
</div>
						
.parent > div[class] {
    animation-name: changeme;
    animation-duration: 10s;
    animation-iteration-count: infinite;
    margin-bottom: 4px;
}
@keyframes changeme {
   0% {
      min-width: 12em;
      width: 12em;
      background-color: black;
      border: 1px solid red;
      color: white;
   }
   100% {
      width: 90vw;
      min-width: 24em;
      background-color: magenta;
      color: yellow;
      border: 1px solid orange;
   }
}
						
.jump-start {
   animation-timing-function: steps(5, jump-start);
}
.jump-end {
   animation-timing-function: steps(5, jump-end);
}
.jump-none {
   animation-timing-function: steps(5, jump-none);
}
.jump-both {
   animation-timing-function: steps(5, jump-both);
}
.start {
   animation-timing-function: steps(5, start);
}
.end {
   animation-timing-function: steps(5, end);
}
.step-start {
   animation-timing-function: step-start;
}
.step-end {
   animation-timing-function: step-end;
}
						

规范

规范 状态 注释
CSS 动画
The definition of 'animation-timing-function' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
animation-timing-function Chrome 完整支持 43 Edge 完整支持 12 Firefox 完整支持 16
完整支持 16
Prefixed Implemented with the vendor prefix: -webkit-
完整支持
Prefixed Implemented with the vendor prefix: -webkit-
Disabled layout.css.prefixes.webkit preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
完整支持 5 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 完整支持 10 Opera 完整支持 30
完整支持 30
Prefixed Implemented with the vendor prefix: -webkit-
不支持 12.1 — 15
不支持 12 — 15 Prefixed
Prefixed Implemented with the vendor prefix: -o-
Safari 完整支持 9 WebView Android 完整支持 43 Chrome Android 完整支持 43 Firefox Android 完整支持 16
完整支持 16
Prefixed Implemented with the vendor prefix: -webkit-
完整支持
Prefixed Implemented with the vendor prefix: -webkit-
Disabled layout.css.prefixes.webkit preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
完整支持 5 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android 完整支持 30
完整支持 30
Prefixed Implemented with the vendor prefix: -webkit-
不支持 12.1 — 14
不支持 12 — 14 Prefixed
Prefixed Implemented with the vendor prefix: -o-
Safari iOS 完整支持 9 Samsung Internet Android 完整支持 4.0
jump- keywords for steps() Chrome 完整支持 77 Edge 完整支持 79 Firefox 完整支持 65 IE 不支持 No Opera 完整支持 64 Safari 完整支持 14 WebView Android 完整支持 77 Chrome Android 完整支持 77 Firefox Android 完整支持 65 Opera Android 完整支持 55 Safari iOS 完整支持 14 Samsung Internet Android 完整支持 12.0

图例

完整支持

完整支持

不支持

不支持

用户必须明确启用此特征。

用户必须明确启用此特征。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  1. CSS
  2. CSS 参考
  3. CSS 动画
  4. 指南
    1. CSS 动画提示和技巧
    2. 检测 CSS 动画支持
    3. 使用 CSS 动画
  5. At-Rules
    1. @keyframes
  6. 特性
    1. <custom-ident>
    2. animation
    3. animation-delay
    4. animation-direction
    5. animation-duration
    6. animation-fill-mode
    7. animation-iteration-count
    8. animation-name
    9. animation-play-state
    10. animation-timing-function

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1