码迷,mamicode.com
首页 > 移动开发 > 详细

移动端rem自适应布局关键代码

时间:2016-04-18 09:59:32      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:

function resi() {
	var html = document.querySelector("html");
	var wW = document.body.clientWidth || document.documentElement.clientWidth;
	var maxW = 640;
	var minW = 320;
	if (wW > maxW) wW = maxW;
	var ratio = wW / minW;
	html.style.fontSize = 50 * ratio + "px"
}
window.addEventListener("DOMContentLoaded", function() {
	var bodys = document.querySelector("body").style;
	bodys.opacity = "1";
	bodys.filter = "alpha(opacity=100)";
	resi()
});
window.addEventListener("resize", resi);

  

移动端rem自适应布局关键代码

标签:

原文地址:http://www.cnblogs.com/FightingTT/p/5403141.html

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