Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

animation-delay: wait before starting or begin partway through

Use positive and negative times while keeping delay, duration and fill behavior separate.

Version: CSS Modules

Syntax

animation-delay: 500ms, -250ms;

In the established time-based syntax, animation-delay accepts a comma-separated list of times matched to animation names. The initial value is 0s. A positive time postpones the active interval; a negative time starts as if that much time had already elapsed. It is not a speed change and does not insert a pause between iterations. A negative offset beyond a finite active duration can put the animation immediately after its active phase.

The delay does not itself specify what is visible outside the active interval. animation-fill-mode decides that: without fill, ordinary styles remain in effect; backwards fill uses the first relevant keyframe, and forwards fill retains the last relevant state. Direction affects which keyframe is first. Pausing an animation also pauses its delay clock. These rules describe the document-time example here, not an assertion about every scroll-driven timeline.

For a one-second opacity change from 0.2 to 0.8 over a base of 0.4, a 500ms delay sampled at 0,500,750,1500ms gives 0.40,0.20,0.35,0.40 without fill. Both-side fill gives 0.20,0.20,0.35,0.80. A -250ms delay sampled at 0,250,750ms gives 0.35,0.50,0.80; -2s is already at the filled final value 0.80.

The current Level 2 draft expands the property into a start/end shorthand using animation-delay-start and animation-delay-end. This is distinct from two comma-separated delays for two animations. Chromium 157 rejects both new longhands and the space-separated pair in the probe. The working behavior above therefore uses the established single delay per animation; draft syntax acceptance is not assumed.

Examples

const style=document.createElement('style');style.textContent='@keyframes fade{from{opacity:.2}to{opacity:.8}}';document.head.append(style);
const sample=(delay,fill,times)=>{const box=document.createElement('div');box.style.cssText='opacity:.4;animation:fade 1s linear 1 normal paused';box.style.animationDelay=delay;box.style.animationFillMode=fill;document.body.append(box);const animation=box.getAnimations()[0];return times.map(time=>{animation.currentTime=time;return Number(getComputedStyle(box).opacity).toFixed(2)}).join(',')};
console.log('positive-none='+sample('500ms','none',[0,500,750,1500]));
console.log('positive-both='+sample('500ms','both',[0,500,750,1500]));
console.log('negative='+sample('-250ms','both',[0,250,750]));
console.log('after-active='+sample('-2s','both',[0])+'; draft-pair='+CSS.supports('animation-delay','1s 2s')+'; start-property='+CSS.supports('animation-delay-start','1s')+'; end-property='+CSS.supports('animation-delay-end','2s'));

Result

positive-none=0.40,0.20,0.35,0.40
positive-both=0.20,0.20,0.35,0.80
negative=0.35,0.50,0.80
after-active=0.80; draft-pair=false; start-property=false; end-property=false

CSS keyframes are sampled through explicit currentTime values, with no real-time waiting. The additional checks concern parsing of draft syntax only; they do not demonstrate an implemented end delay.

Sources