How to make text take full width of it's container?

Say the div have 300px of width, how would I set the font-size of the text, so that it would always take 100% of the width, considering the text is never the same length (the text is some dynamic titles that I generate, but never long, but still dynamic). Smaller text would have to have a font a lot smaller than the bigger text, etc
1 Reply
Wolle
Wolle2y ago
Measure the width of the container and element, calculate the multiplier and increase the font-size by that multiplier. container.clientWidth / element.clientWidth
Want results from more Discord servers?
Add your server