h5rem.js
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘, // pieces = 750, recalc = function () { var clientWidth = docEl.clientWidth; if (!clientWidth) return; // docEl.style.fontSize = 100 * (clientWidth / pieces) + ‘px‘; docEl.style.fontSize = clientWidth / 8 +‘px‘; //pieces 是在gulp px2rem插件中设置的参数 }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener(‘DOMContentLoaded‘, recalc, false); })(document, window);
gulp-px2rem-plugin 插件配置教程 地址