Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

transition-delay — transition start offset

The transition-delay property sets the start offset of a CSS transition: positive values introduce a wait, while negative values skip the beginning if part of the transition still remains.

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

Syntax

transition-delay: <time>#;

transition-delay accepts times in s or ms. Its initial value is 0s; it is neither inherited nor animatable. It does not trigger a style change itself.

Positive values postpone the transition, retaining its starting value while waiting. 0s starts immediately. A negative delay starts the transition immediately, partway through, but only if the duration plus the delay is positive. With transition-duration: 1s, a delay of -250ms skips the first 250 ms. If the magnitude of the negative delay equals or exceeds the duration, no transition starts.

Comma-separated entries match transition-property order: missing entries repeat, surplus entries are ignored. In the transition shorthand, the first time is duration, the second delay. Do not confuse waiting time with the duration of the change itself.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Transition start delay</title>
  <style>
    .box {
      width: 60px;
      height: 60px;
      margin-block-start: 12px;
      background: navy;
      transform: translateX(0px);
      transition-property: transform;
      transition-duration: 1s;
      transition-timing-function: linear;
      transition-delay: 500ms;
    }
    #move:checked ~ .box { transform: translateX(120px); }
  </style>
</head>
<body>
  <input id="move" type="checkbox">
  <label for="move">Move the square</label>
  <div class="box" aria-hidden="true"></div>
  <script>
    const move = document.getElementById('move');
    const box = document.querySelector('.box');
    const style = getComputedStyle(box);
    console.log(`Computed delay: ${style.transitionDelay}`);
    // Commit the starting transform before changing the checked state.
    const horizontalOffset = () => Math.round(new DOMMatrixReadOnly(style.transform).m41);
    console.log(`Before checking: ${horizontalOffset()}px`);
    move.checked = true;
    const [motion] = box.getAnimations();
    motion.pause();
    for (const time of [250, 1000, 1500]) {
      motion.currentTime = time;
      console.log(`At ${time}ms: ${horizontalOffset()}px`);
    }
    // Finish the demonstration and leave the checkbox usable.
    motion.finish();
  </script>
</body>
</html>

Result

Computed delay: 0.5s
Before checking: 0px
At 250ms: 0px
At 1000ms: 60px
At 1500ms: 120px

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