2

Is is possible to set the text size in CSS such that it adjusts to the container width?

I made an example for that. The left container is small which should make the font size smaller than for the right container. I know how this is done with JavaScript, but can I also be done with pure CSS?

enter image description here

confile
  • 30,949
  • 47
  • 199
  • 357

1 Answers1

2

You can use viewport units instead of pixels, points or em. It's a CSS3 property.

1vw: 1% of viewport width
1vh: 1% of viewport height
1vmin: 1vw or 1vh, whatever is smallest
1vmax: 1vw or 1vh, whatever is largest

More info here.

otinanai
  • 3,857
  • 2
  • 23
  • 43