Say I have a text container, can the font auto adjust so that the text inside fits in exactly one line and takes up the entire container width without overflowing? With only CSS.
Like hypothetically if I had a and I set the font size to auto, and auto did the thing I described earlier.
2
Answers
Is the text a fixed length? If so, you could set the font size to a portion of the view width. It would take some trial-and-error to get the exact value.
Something like this:
With a dynamic text length it’s a bit more complicated; I don’t know a way to do it without using JavaScript. Perhaps a calc() function?
Related:
https://www.w3schools.com/cssref/css_units.php
https://www.w3schools.com/css/css_math_functions.asp
To make the text fit exactly one line and take up the entire width of a container using only CSS, use: