Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

transition-timing-function — CSS transition pacing

The transition-timing-function property determines how elapsed-time progress maps to value-change progress during a CSS transition. It enables uniform motion, acceleration, deceleration, or jumps without changing the declared duration.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

transition-timing-function: <easing-function>#;

transition-timing-function maps a transition’s time progress to interpolation progress for the changing property. It does not set duration or delay: those belong to transition-duration and transition-delay. It does not start a transition by itself; a property covered by the transition must change value.

The initial value is ease. The property is not inherited and is itself not animatable. The syntax <easing-function># means one or more functions, separated by commas. Functions match positions in transition-property; a shorter list repeats, and excess entries are not used.

linear gives uniform progress, ease-in starts slowly, ease-out slows near the end, and ease-in-out softens both ends. cubic-bezier() defines a custom curve, while steps() produces jumps. Do not confuse the linear keyword with the linear() function: the latter defines a custom piecewise-linear progression.

The example compares linear and ease-in with identical displacement and a duration of 2s. The script automatically checks Move both squares, logs both squares’ positions at 1000ms and 2000ms, and then finishes both transitions. The checkbox stays checked. Uncheck it to watch the squares move back, and wait for them to finish before checking it again: reversing a running transition can shorten the return time.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Linear and ease-in transitions</title>
  <style>
    .track { width: 240px; background: #eee; }
    .box {
      width: 40px;
      height: 40px;
      background: #2457c5;
      transform: translateX(0px);
      transition-property: transform;
      transition-duration: 2s;
      transition-timing-function: linear;
    }
    .eased { transition-timing-function: ease-in; }
    #move:checked ~ .track .box { transform: translateX(200px); }
  </style>
</head>
<body>
  <input id="move" type="checkbox">
  <label for="move">Move both squares</label>
  <p>Linear</p>
  <div class="track" aria-hidden="true"><div class="box"></div></div>
  <p>Ease-in</p>
  <div class="track" aria-hidden="true"><div class="box eased"></div></div>
  <script>
    const move = document.getElementById('move');
    const boxes = [...document.querySelectorAll('.box')];
    const styles = boxes.map(box => getComputedStyle(box));
    function offsets() {
      return styles.map(style => Math.round(new DOMMatrixReadOnly(style.transform).m41));
    }
    console.log(`Timing functions: ${styles.map(style => style.transitionTimingFunction).join(', ')}`);
    console.log(`Before checking: ${offsets().join('px, ')}px`);
    move.checked = true;
    const motions = boxes.map(box => box.getAnimations()[0]);
    for (const motion of motions) motion.pause();
    for (const time of [1000, 2000]) {
      for (const motion of motions) motion.currentTime = time;
      console.log(`At ${time}ms: ${offsets().join('px, ')}px`);
    }
    for (const motion of motions) motion.finish();
  </script>
</body>
</html>

Result

Timing functions: linear, ease-in
Before checking: 0px, 0px
At 1000ms: 100px, 63px
At 2000ms: 200px, 200px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources