h5页面px和rem单位的自动换算

 

转载自: https://blog.csdn.net/lianwenxiu/article/details/87897453


放到index.html下
750 //设计图宽度

(function(doc, win) {
var docE1 = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange': 'resize', recalc = function() { var clientWidth = docE1.clientWidth; if (!clientWidth) return; docE1.style.fontSize = 100 * (clientWidth / 750) + 'px'; }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); })(document, window);

 

posted @ 2020-11-19 15:36  龙卷风吹毁停车场  阅读(631)  评论(0编辑  收藏  举报