RevealTheme logo

Trình tạo CSS Clamp()

Tạo các giá trị CSS linh hoạt và đáp ứng với clamp(). Co giãn mượt mà giữa kích thước tối thiểu và tối đa trên các khoảng của viewport.

font-size: clamp(16px, 13.0909px + 0.9091vw, 24px);

Cách sử dụng công cụ này

  1. 1

    Enter the minimum size in pixels (the value at and below your small viewport).

  2. 2

    Enter the maximum size in pixels (the value at and above your large viewport).

  3. 3

    Set the min and max viewport widths in pixels that define where scaling starts and stops.

  4. 4

    Read the generated clamp() declaration and click Copy to paste it into your stylesheet.

Trình tạo CSS Clamp() là gì?

Hàm CSS clamp(tối thiểu, ưa thích, tối đa) giữ một giá trị nằm trong giới hạn trong khi vẫn cho phép nó co giãn mượt mà trong khoảng đó. Hoàn hảo cho kiểu chữ đáp ứng tăng dần mượt mà theo chiều rộng của viewport thay vì nhảy đột ngột tại các điểm ngắt. Công cụ này tính toán công thức giá trị ưa thích chính xác từ kích thước phông chữ tối thiểu/tối đa và chiều rộng viewport của bạn.

Các trường hợp sử dụng phổ biến

  • Building fluid headings that grow from 24px on mobile to 48px on desktop without writing media-query breakpoints.

  • Setting responsive body copy that stays readable between a 320px phone and a 1200px laptop.

  • Scaling section padding or gap values fluidly so layouts breathe proportionally across screen sizes.

  • Replacing a stack of font-size overrides at 480px, 768px, and 1024px with one clamp() declaration.

  • Generating clamp() values for a design system so spacing and type scale consistently from one formula.

  • Quickly checking the px and vw math for a fluid value you sketched out in a design tool like Figma.

Câu hỏi thường gặp

Khả năng tương thích với trình duyệt?
clamp() hoạt động trên tất cả các trình duyệt kể từ năm 2020: hoàn toàn an toàn để dùng trong production.

Công cụ liên quan