How to resize font-size proportionally to div size

user1116779 picture user1116779 · Dec 26, 2011 · Viewed 7.2k times · Source

I'm trying to create a website where the pages resize to the windows size on the fly. While we can get images and such to resize automatically as a % of the div size. We do not seem to be able to resize the text within a div to a relative % of the container.

This feature would need to work as the browser window itself is resized, without having to refresh the page.

The site is basic and is using js,css, html. The simplest method possible would be appreciated, but any solution is fantastic.

Thanks

Answer

Calvin picture Calvin · Dec 28, 2011

Whipped up some example to adjust font-size on div size change. Using percentage in the parent div and adjusting the font-size there should do the trick.

http://jsfiddle.net/744A2/