标签:
假设根字体font-size的值是40px, 640/40=16,16就是px换算rem的值
function initHtmlFontSize(){
//获取可是宽度
var _width=documnet.body.clientWidth;
//判断
_width= _width > 640 ? 640:_width;
//当前的font-size的值
var _fs=_width/16;
//赋给html节点
document.getElementsByTagName(‘html‘)[0].style.fontSize=_fs + ‘px‘;
}
initHtmlFontSize()
学习web前端技术的笔记,仅供自己查阅备忘,移动对font-size的控制(并非原创)
标签:
原文地址:http://www.cnblogs.com/opcec/p/5430186.html