js resize text

by ian_smithz

HTML

<div>Scale the window</div>

CSS

div {
    font-size:2em;
}

JavaScript

document.body.setScaledFont = function (f) {
       var s = this.offsetWidth,
           fs = s * f;
       this.style.fontSize = fs + '%';
       return this
   };

   document.body.setScaledFont(0.35);
   window.onresize = function () {
       document.body.setScaledFont(0.35);
   }