188
rated 0 times
[
190]
[
2]
/ answers: 1 / hits: 22386
/ 10 Years ago, fri, march 21, 2014, 12:00:00
There are many jQuery plugins that let you resize a text to fit a container. But how can you dynamically change the width/height of a div container to fit the text inside of it?
Below an example. As you can see the text is currently overflowing the div. How can you programatically resize the container div to fit the text independent of the font size and content?
<!DOCTYPE html>
<html>
<body>
<div id=container style=width:100px; height:100px;border:1px solid red; overflow: hidden;>
<p style=font-size:40px;>This is the text</p>
</div>
</body>
</html>
More From » jquery