I have a fixed size <header>
(let's say 300px in width by 200px in height) and a text inside. Here's my structure:
Header 1:
<header>
<h1>
This is example title, but the text length might be different.
</h1>
</header>
I have multiple headers just like this, but with various text length, example:
Header 2:
<header>
<h1>
This is small-length text.
</h1>
</header>
Header 3:
<header>
<h1>
This is bigger-length text. This is example title, but the text length might be different.
</h1>
</header>
I want scale the text font-size in this fixed-size <header>
as much as possible (without exceeding the <header>
bounds, in width and height). And I want to do it dynamically, so it matches any text length. Do you have any ideas how I can do that?
PS: Here's a JS fiddle that illustrates the problem: https://jsfiddle.net/superKalo/nqf46tft/
Edit: I assume a CSS only solution is not possible. Do you know any javascript trick that would solve this problem?