SashayAway SashayAway - 2 months ago 5
HTML Question

Automatic font resize, how is it possible?

WEBSITE URL https://www.allcarfinance.com/

I would like to know what this website is using to make the font-size bigger or smaller automatically depending how big is your browser windows.

I think it is not just @media font-size: 14px... because if you check it with the Google Inspector, the font-size changes a very specific size like: 20.3579px. I think the website is calculating a font size between two numbers, for example: 14 to 25.

How is it possible?

Answer

Use vw(viewport width) it resizes the font according to window size.

h1 {
  font-size: 5.9vw;
}
h2 {
  font-size: 3.0vh;
}
p {
  font-size: 2vmin;
}

https://jsfiddle.net/dolphine/uj50trfn/

Comments