I'm trying to scale text based on the parent div. I'm using reactjs and I've tried to use the react-textfit package, but the font size is defined in pixels making it not responsive.
Remembering that the texts are dynamic. I don't know how many letters each will have
I make this example in https://jsfiddle.net/2hsz16q8/6/
here i did it using a second class but, i would like to do this dynamically.
HTML:
<ul>
<li>
<div>
<h1 id="dynamic-text-1">Why do we use it?</h1>
</div>
</li>
<li>
<div>
<h1 id="dynamic-text-2">Where does it come from?</h1>
</div>
</li>
</ul>
CSS:
#dynamic-text-1 {
font-size: 4em;
}
#dynamic-text-2 {
font-size: 2.9em;
}
div {
border: 1px solid red;
width: 70vw;
}