Instal ZYBERMART

Buka semua alat dari layar utama atau dock, di jendelanya sendiri. Alat yang pernah Anda gunakan juga bisa dipakai offline.

Kalkulator CSS Clamp

Hitung nilai CSS clamp() yang berubah mulus antara ukuran minimum dan maksimum di berbagai lebar layar.

Typical phone width.
Typical desktop width.

CSS


            

Preview: drag to change the screen width

Aa Fluid type

The formula

slope = (maxSize − minSize) ÷ (maxWidth − minWidth)

intercept = minSize − slope × minWidth

font-size: clamp(minSize, intercept + slope × 100vw, maxSize);

Example

Text that grows from 18px on a 375px phone to 32px on a 1280px desktop: the slope is 14 ÷ 905 ≈ 0.01547, so the preferred value is about 0.7624rem + 1.547vw, giving clamp(1.125rem, 0.7624rem + 1.547vw, 2rem).

Good uses for fluid sizes

  • Headings that are large on desktop but don't overflow on phones.
  • Section padding and gaps that grow with the screen.
  • A whole type scale: calculate one clamp() per heading level.

Frequently asked questions

What does CSS clamp() do?

clamp(min, preferred, max) returns the preferred value, but never less than the minimum or more than the maximum. With a preferred value based on the viewport width (vw), sizes scale smoothly between two screen widths and stop at sensible limits.

Why use rem instead of px?

rem is relative to the root font size, so text still grows when someone increases their browser's default font size, which is important for accessibility. The calculator outputs rem by default and converts using the root size you set (usually 16px).

How is the formula calculated?

The size grows in a straight line between the two viewport widths. The slope is (max size − min size) ÷ (max width − min width). The preferred value is then intercept + slope × 100vw, where the intercept makes the line pass through the minimum point.

Is clamp() supported everywhere?

Yes. clamp() works in all current browsers, including Safari on iPhone. It can be used for font sizes, padding, margins, gaps and widths.

Masuk ke ZYBERMART

Simpan CV, invoice, flashcard, catatan, dan alat tersimpan Anda di semua perangkat. Gratis, dan semua alat tetap berfungsi sama tanpa akun.

atau

Tanpa kata sandi. Dengan masuk, Anda menyetujui ketentuan kami; lihat cara kami mengelola data Anda di kebijakan privasi.

Akun Anda

Saat keluar, salinan pekerjaan Anda tetap tersimpan di browser ini. Di komputer bersama, hapus data browser setelahnya.

Apa yang ingin Anda buat?

Desain

Media sosial

Dokumen

Belajar

Edit

Lihat semua 282 alat