Dev Helpers

CSS / Responsive layout

Apply fluid spacing with a ceiling

Dev Helpers · July 12, 2026

A clamp combines a minimum, a fluid middle value and a maximum. The ceiling keeps generous desktop spacing from growing indefinitely.

Worked example

<style>
  .demo {
    padding: min(6vw, 2rem);
  }
</style>
<div class="demo">Apply fluid spacing with a ceiling</div>

Implementation notes

Use a fluid middle term with compatible units. A clamp whose preferred value never leaves its limits behaves like a fixed spacing token.

Try it yourself

Resize past both bounds and inspect the computed padding.

Open the CSS example →

Editorial date July 12, 2026 · Published December 6, 2026

Related articles

Fluid width with a maximum

A fluid container needs a small-screen width and a large-screen maximum. Outer gutters should remain visible at both extremes.

Square aspect ratio

A square ratio reserves equal sides even before media loads. Fit rules decide whether rectangular content is cropped or letterboxed.