I'm attempting to dynamically resize text within a div, similar to the functionality shown in this example.
As I resize the div, I want the font size to adjust accordingly.
I've tried using various relative length units in pure CSS for the text element, but it hasn't been successful. It seems that setting the font-size based on the div size (rather than viewport width) may require JavaScript.
<style>
div {
border: 2px solid;
padding: 20px;
width: 300px;
resize: both;
overflow: auto;
}
</style>
<div>
<p style="font-size: 2rem">Hello World</p>
</div>
What is the most effective approach for achieving this goal, ideally using Bootstrap 4 or pure CSS?