8.4 · Typography & shape
Responsive clip paths: shape()
Responsive clip-path curves in percentages and rem.
clip-path: path() could draw curves, but only in pixels,
so the shape didn’t scale with the element. shape() uses
the same commands, line, hline,
vline and curve, with any CSS unit,
percentages and calc().
Shapes stay correct at every size and can be animated or driven by custom properties.
/* Pixels only: breaks when it resizes */
clip-path: path(
'M0 0 H400 V160 Q300 200 200 160 …'
);
clip-path: shape(
from 0 0,
hline to 100%,
vline to calc(100% - var(--wave)),
curve to 50% calc(100% - var(--wave))
with 75% 100%,
…
);