Adaptive font-size using container query size

Container queries are the best thing ever. Even now more so using it to make a fancy title always grow with it's parent or even become smaller when parent is smaller.

It's as simple as:

.card-with-title {
/* By setting container-type to inline-size we can then use Container query length units */
container-type: inline-size;
h2 {
font-size: 18cqi;
text-transform: uppercase;
font-family: "Impact", sans-serif;
}
}

Container query units

All the container query length units are:

For more info check MDN

Codepen example

See the following example codepen:

See the Pen Adaptive font-size using container query by Wonky (@Wonky) on CodePen.