您的位置:首页 > 移动开发

移动端rem布局中,当显示横屏时,解决根目录font-size切换屏幕不变情况(相较于引用rem.js方案的不足)

2016-12-07 00:00 627 查看
/* 长宽占位 rem算法, 根据root的rem来计算各元素相对rem, 默认html 320/16 = 20px */
function placeholderPic(){
var w = document.documentElement.offsetWidth ;
document.documentElement.style.fontSize= w / 16 + 'px' ;
}
placeholderPic();
window.onresize = function(){
placeholderPic();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: