CSS Clamp Generator

Create fluid sizes that grow between a minimum and maximum viewport.

Loading tool...

How to use CSS Clamp Generator

  1. Enter the minimum and maximum size in pixels.
  2. Enter the viewport widths where scaling starts and stops.
  3. Copy the clamp() value.

About this tool

clamp(min, preferred, max) keeps a value between a lower and upper bound while the preferred part scales with the viewport width. The generator computes the linear preferred value so the size equals your minimum at the small viewport and your maximum at the large one.

Using rem in the bounds keeps the text responsive to user font size settings.

Frequently Asked Questions

Why mix rem and vw?
The vw part scales with the screen and the rem part keeps the value responsive to user settings.
What viewports should I use?
Common choices are 320 px for small phones and 1200 to 1440 px for desktops.

Related tools