Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

linear(): piecewise linear animation easing

Describe an easing curve with explicit output values and optional input progress positions.

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

Syntax

animation-timing-function: linear(0, 0.5 80%, 1);

linear() is an easing function made of straight segments between control points. The numbers are output progress values, while optional percentages locate them along input progress. This makes it different from the simple linear keyword: linear(0, 0.5 80%, 1) reaches only half the output after 80% of the input, then completes the remaining half in the final 20%.

A control point can specify two input positions, keeping the same output over that interval and producing a plateau. Omitted positions are distributed according to the specification; supplied positions are fixed up into nondecreasing order. Output numbers can leave the 0–1 range to express overshoot. The function maps progress; it does not set the animation duration, start it, or guarantee smooth physical acceleration at each segment boundary.

The example pauses a one-second Web Animations animation and sets its current time directly. A 0-to-100 pixel translation measures 25 pixels at 400 ms, 50 at 800 ms and 75 at 900 ms. Deterministic sampling verifies the segment slopes without relying on wall-clock timing or a visible animation staying in the foreground.

Examples

const element=document.createElement('div');document.body.append(element);
const animation=element.animate([{transform:'translateX(0px)'},{transform:'translateX(100px)'}],{duration:1000,fill:'both',easing:'linear(0, 0.5 80%, 1)'});
animation.pause();await animation.ready;
const positions=[];for(const time of [400,800,900]){animation.currentTime=time;positions.push(time+'ms='+new DOMMatrix(getComputedStyle(element).transform).m41.toFixed(2)+'px')}
console.log(positions.join('; '));animation.cancel();

Result

400ms=25.00px; 800ms=50.00px; 900ms=75.00px

The changing slope is intentional: each segment is linear, but the overall movement is not constant-speed.

Sources