CSS clamp() Calculator

Create fluid, responsive sizes that scale smoothly between two viewport widths.

Size (px)

Viewport (px)

Advertisement

What this tool does

The CSS clamp() function sets a value that grows with the viewport but never goes below a minimum or above a maximum. This calculator builds the exact clamp(min, preferred, max) expression so your font sizes and spacing scale smoothly across devices — “fluid typography” — without a jump at each breakpoint.

How it works

Between your minimum and maximum viewport widths, the size interpolates linearly. The preferred value uses vw plus a rem offset so it hits your min size at the small viewport and your max size at the large one.

Example

A heading that is 16px on a 360px phone and 24px on a 1200px desktop produces a single clamp() value you can drop into font-size.

Advertisement