码迷,mamicode.com
首页 > 其他好文 > 详细

rem适配

时间:2016-07-14 10:21:30      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

//REM适配
new function() {
var _self = this;
_self.width = 640; // 设置默认最大宽度
_self.fontSize = 100; // 默认字体大小
_self.widthProportion = function() {
var p = (document.body && document.body.clientWidth || document.getElementsByTagName("html")[0].offsetWidth) / _self.width;
return p > 1 ? 1 : p < 0.5 ? 0.5 : p;
};
_self.changePage = function() {
document.getElementsByTagName("html")[0].setAttribute("style", "font-size:" + _self.widthProportion() * _self.fontSize + "px !important; display:block");
}
_self.changePage();
window.addEventListener(‘resize‘, function() {
_self.changePage();
}, false);
};

rem适配

标签:

原文地址:http://www.cnblogs.com/zhouyx/p/5669280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!