rem自适应js代码

以后懒得写,直接复制了

var computedFz = (function(){
  var designWidth = 375, rem2px = 100;
  function computedFz(){
	var fz = Math.floor(window.innerWidth / designWidth * rem2px);
	document.documentElement.style.fontSize = (fz > 100 ? 100 : fz) + 'px'
  }
	return computedFz;
})()
computedFz();
window.onresize = function(){
  setTimeout(computedFz,500);
}

  

posted @ 2017-08-30 22:08  疾风_剑豪  阅读(352)  评论(0编辑  收藏  举报