Creates text that scales according to the viewport width.
- Use the
clamp()CSS function to clamp the value offont-sizebetween1remand3rem. - Use the formula
8vw - 2remto calculate a responsive value forfont-size(1remat600px,3remat1000px).
预览
Hello World!
HTML
<p class="fluid-type">Hello World!</p>
CSS
.fluid-type {
font-size: clamp(1rem, 8vw - 2rem, 3rem);
}