页面REM单位配合JS实现 --- PX2REM
页面REM单位配合JS实现
JS 下载:https://github.com/hixiaoguan/html5-px2rem/blob/master/html5-px2rem-new.js
----HTML----
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no,viewport-fit=cover">
----JS----
//rem adaptive (function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; var recalc = function () { var width = docEl.clientWidth; if (width > 640) { width = 640 ; } if (width < 320) { width = 320 ; } docEl.style.fontSize = 100 * (width / 640) + 'px'; }; recalc(); if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); })(document, window);