移动端适配1px问题
(function(document) { var dcl = document.documentElement, wh; var scale = 1/window.devicePixelRatio; document.querySelector('meta[name="viewport"]').setAttribute('content','initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no'); function setRootRem() { wh = dcl.clientHeight; dcl.style.fontSize = 100 * (wh / 1334) + 'px'; } setRootRem(); document.addEventListener('DOMContentLoaded', setRootRem, false); window.addEventListener('resize', setRootRem, false); })(document);
但是这样会导致在iphone6时输出document.documentElement.clientWidth为750.与传统获取为375不符合。