✨ The idea of fluid typography has been around in application development for a while, but to make this work in the browser, developers had to use a variety of solutions.
👨💻 Depending on the viewport width, fluid typography adjusts nicely between the minimum and maximum value. Typically, it starts at a minimum value and stays constant until a certain screen width point, at which time it starts to rise. When it hits a maximum value at a different screen width, it keeps going with that maximum value.
👨🏫 For instance, if we wanted our font size to be between 2em and 3em, where 2em is the minimum size at the smallest viewport width of 320px and 3em is the maximum size at the highest viewport width of 1366px. Then our equation will look like this -
font-size: calc(2em + 1 * (100vw - 320px) / 1046);
@media (min-width: 1366px){
.fluid-h2 {
font-size: 3em;
}
}
@media (min-width: 320px){
.fluid-h2 {
font-size: calc(2em + 1 * (100vw - 320px) / 1046);
}
}
.fuild-h2 {
font-size: 2em;
font-weight: 600;
line-height: 1.21;
}