Responsive Typography

It appears that by using calc() and vw we can get responsive typography that scales perfectly between specific pixel values within a specific viewport range.

The problem with the common approach to responsive typography is that it is jumpy and requires a lot of media queries.

Viewport units are fluid but lack precise control over font-size.

Typically you might use a table like this to work out the range of font sizes across different resolutions.

Viewport units:1vw2vw3vw4vw5vw
Viewport sizefont-size in pixels
400px4px8px12px16px20px
500px5px10px15px20px25px
600px6px12px18px24px30px
700px7px14px21px28px35px
800px8px16px24px32px40px
900px9px18px27px36px45px
1000px10px20px30px40px50px
1100px11px22px33px44px55px
1200px12px24px36px48px60px

Looking at the table you can see there are many limitations. There is no way to scale between 16px and 36px for example over the given viewport sizes. That is a shame because this is the type of control designers expect (and should expect).

Imagine you want the smallest font-size to be 12 pixels and then once the device width is greater than 400px you want the font-size to gradually increase to 24px and stop scaling by the time the viewport reaches 800px. That is exactly what this demo does!

This is achieved by using viewport units in combination with calc().


More details here: https://madebymike.com.au/writing/precise-control-responsive-typography/

Get the SCSS mixin: https://codepen.io/MadeByMike/pen/vNrvdZ

See all examples in the collection: https://codepen.io/collection/nLbRMZ

Read about it on Smashing: https://www.smashingmagazine.com/2016/05/fluid-typography/