CSS spring and bounce with linear()
How CSS linear() gives you spring and bounce easing without JavaScript, and how much error you get from 8 to 96 stops, measured on my own easing code.
· Updated · 4 min read

linear() is a CSS easing function that takes a list of points and draws straight lines between them. With enough points it traces a spring or a bounce, which cubic-bezier() cannot do. Every current browser supports it, and in my tests 48 points were enough for most UI moves.
I added spring, bounce and elastic export to my Easing Editor, so I measured how far a sampled curve drifts from the real one at different point counts. The numbers are below.
What cubic-bezier cannot do#
A cubic-bezier() curve has two control points. It can overshoot the target once and settle, but it cannot swing past three times and die out like a real spring, and it cannot hit the ground and bounce. CSS also limits the horizontal handles to the 0 to 1 range, so only the vertical handles can push the curve past the end value.
linear() has no such limit. You list the progress values and the browser joins them.
How linear() reads#
The syntax comes from MDN. You give at least two numbers. Each number can carry one or two percentages that say where the point sits. Without percentages the points are spread evenly. Values outside 0 to 1 are allowed, which is how a spring overshoots.
/* 0 at the start, 1.2 halfway, 1 at the end */
transition: transform 1s linear(0, 1.2 50%, 1);
Browser support is the part that used to hold this back. MDN marks linear() as Baseline widely available, with support across browsers since December 2023. The Chrome documentation lists the first versions: Chrome and Edge 113, Firefox 112, Safari 17.2.
Turning a spring into points#
Writing the points by hand is out of the question, so you sample a function. My spring is the standard under-damped formula, 1 - e^(-ζωt) · (cos(ω_d t) + ζω/ω_d · sin(ω_d t)), and the export is a short loop:
export function toLinear(curve: Curve, stops: number): string {
const n = clamp(Math.round(stops), 4, 120);
const pts: string[] = [];
for (let i = 0; i <= n; i++) {
const t = i / n;
const v = i === 0 ? 0 : i === n ? 1 : round(curve(t));
pts.push(String(v));
}
return `linear(${pts.join(", ")})`;
}
It samples the curve at evenly spaced times, rounds each value to three places and pins the ends to exactly 0 and 1. The tool uses the same function for spring, bounce and elastic.
How many points you need#
I rendered each curve at the middle liveliness setting with 8, 12, 24, 48 and 96 points. Then I compared the straight-line version with the true curve at 2,000 positions and kept the largest gap. The gap is a share of the full move, so on a 300 px slide, 10% means 30 px.
| Points | Spring | Bounce | Elastic | Spring length in CSS |
|---|---|---|---|---|
| 8 | 26.6% | 11.8% | 13.4% | 48 characters |
| 12 | 12.4% | 12.6% | 8.6% | 68 |
| 24 | 8.9% | 8.2% | 2.2% | 126 |
| 48 | 3.5% | 1.7% | 0.7% | 242 |
| 96 | 1.0% | 1.2% | 0.2% | 481 |
Two things stand out.
The error does not fall smoothly. Bounce gets slightly worse from 8 to 12 points (11.8% to 12.6%), and the spring only improves from 12.4% to 8.9% when the points double from 12 to 24, because evenly spaced samples can step over a peak. The Chrome documentation shows the same effect: a rough curve with few points becomes smooth when you add more. In my table the big drop comes from 24 to 48.
The file cost is tiny. Even 96 points is 481 characters. The real price of more points is readability, so I keep the list in a custom property and never look at it again.
For a slide of 300 px, 48 points leave a gap of about 10 px at the worst moment. For a 40 px nudge it is 1.4 px. I start at 48 and drop lower only for small moves.
These numbers measure my sampler against my own formulas. I have not compared them with other generators, and a generator that places points where the curve bends can reach the same error with fewer of them.
Using it#
:root {
--spring: linear(0, 0.009, 0.035, /* ...48 points... */ 1);
}
.card {
transition: transform 700ms var(--spring);
}
.card:hover {
transform: translateY(-8px);
}
Overshoot only works on properties that can leave their range. transform can. opacity is clamped to 0 to 1, so a spring on opacity just sits at 1 for a while.
A spring has no natural duration, so you pick one. I use 600 to 800 ms for UI and watch where the motion visibly stops.
Reduced motion#
A spring that overshoots is exactly the sort of motion some people turn off. MDN's guidance for prefers-reduced-motion is to replace large movement such as scaling and panning with gentler effects like fades.
@media (prefers-reduced-motion: reduce) {
.card {
transition: opacity 150ms linear;
}
}
When to reach for JavaScript#
linear() is a recorded curve with a fixed duration. If you need a spring that settles on its own time, or you animate with GSAP already, a JavaScript animation is the better tool. The Easing Editor still helps there: it names the closest built-in GSAP ease for any curve you draw and shows the average gap between the two.
Try it#
Open the Easing Editor, pick Spring, Bounce or Elastic, set the number of points, and copy the CSS. The curve and the settings live in the URL hash, so you can share a link to exactly what you built.