title | tags | expertise | author | firstSeen | lastUpdated |
---|---|---|---|---|---|
Fluid typography |
visual |
intermediate |
chalarangelo |
2021-05-16 11:23:05 +0300 |
2021-05-16 11:23:05 +0300 |
Creates text that scales according to the viewport width.
- Use the
clamp()
CSS function to clamp the value offont-size
between1rem
and3rem
. - Use the formula
8vw - 2rem
to calculate a responsive value forfont-size
(1rem
at600px
,3rem
at1000px
).
<p class="fluid-type">Hello World!</p>
.fluid-type {
font-size: clamp(1rem, 8vw - 2rem, 3rem);
}