CSS generator

CSS Clamp Fluid Size Calculator

Smoothly scale fonts or spacing between two Viewport breakpoints, instantly getting ready-to-use clamp()

Dimensions and Viewport

Commonly used presets

Viewport instant preview

Fluid typography preview

Drag the upper Slider to observe the continuous changes in size

Current actual size
scale slope
Valid range

Generated CSS

How to create fluid layout using clamp()?

clamp(最小值, 偏好值, 最大值) Change fixed breakpoints to continuous scaling. The calculator finds a linear function based on two Viewport widths: the intercept is responsible for the starting size, and the vw coefficient determines how much the viewport should grow with each additional segment of width. When the result is below the minimum value or above the maximum value, the browser automatically locks the upper and lower limits.

Setting method

  1. First decide the minimum acceptable size for small screens and the maximum size for wide screens.
  2. Set the Viewport to start and stop zooming. The common range is 320px to 1280px.
  3. Use the slider to view the middle size and copy the entire CSS declaration.

It is usually recommended to use rem as the upper and lower limits for fonts, so that users can still benefit from adjusting the browser's default font level; if the layout spacing needs to be accurately aligned, px can also be used.

Frequently Asked Questions

What is CSS clamp()?
It accepts three values: minimum, preference and maximum. When the preference value is within the range, the preference value is used, and when it exceeds it, it is automatically limited.
Why is the preference value a combination of calc() and vw?
A fixed intercept plus a vw scale describes a line, allowing the dimensions to grow smoothly with the Viewport.
Which one should I choose between px and rem?
Priority is given to rem for fonts; px is optional for decorative sizes that require precise control of pixels. This tool will convert based on the font size.
Can it be used in padding or gap?
Yes. Any property that accepts a CSS length value and whose browser supports clamp() will work.
Why does the maximum Viewport have to be larger than the minimum Viewport?
The two points need different horizontal positions to calculate the slope; the same width will cause division by zero and no fluid interval can be formed.