用resetfont.js实现字体响应式


window.onload=function(){

    // 开始
    function setSize(){
        var winWidth=window.innerWidth;
        document.getElementsByTagName("html")[0].style.fontSize=winWidth*16/320+"px";
        // 修改根元素的字体大小;
    }
    setSize()
    window.onresize=function(){
        setSize()
    }
    // 结束
}

在html页面中全部以rem单位记;不需要用@media screen and (max-width:600px)

 

 

 

posted @ 2015-06-25 21:53  灰太狼博客  阅读(812)  评论(0)    收藏  举报