CSS Clamp and Fluid Sizing
Generate a linearly fluid CSS length from two viewport widths
Results
—px
- CSS clamp() expression
- —
- Slope
- —px/px
- Intercept
- —px
Results update automatically when the required values are entered.
Method, applicability and sources
Calculation method
Slope = (maximum size − minimum size) / (maximum width − minimum width). Intercept = minimum size − slope × minimum width. CSS vw coefficient =100 × slope. For rem output, divide sizes and intercept by the entered px per rem. clamp(lower bound, intercept + vw term, upper bound) fixes values beyond the boundaries.
Worked example (hypothetical values)
Example: 16 px at 320 px width and 24 px at 1280 px gives slope 1/120 and size 20 px at midpoint width 800 px. With 1 rem =16 px: clamp(1rem, calc(0.833333333333rem + 0.833333333333vw), 1.5rem).
Applicability and limitations
Web layouts with nonnegative CSS lengths that increase monotonically with width. Does not support sizes that decrease with width, container queries, units such as vh or cqw, detection of the browser's root font size, or property-specific value constraints.
Methods used
- Linear CSS length interpolation with clamp() (Linear interpolation v1.0 / CSS Values 4 WD 2024-03-12): scope CSS lengths that do not decrease as width increases; region global
Method and sources
Method: W3C CSS Values and Units Level 4 (Working Draft March 12, 2024) / linear interpolation v1.0. Data recorded: 2026-11-14.