How to resize font-size proportionally to div size

后端 未结 4 1209
情歌与酒
情歌与酒 2021-01-18 20:32

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

4条回答
  •  既然无缘
    2021-01-18 20:59

    So you can use screen.availHeight to calculate a constant value which you can multiply with the font size.

    window.onload = function () {
        document.body.style.fontSize = (Math.ceil(screen.availHeight * parseInt(document.body.style.fontSize) / 600) + 'px';
    }
    

提交回复
热议问题