1. 程式人生 > >PX轉REM

PX轉REM

color ont str ron add als fonts tel script

PX轉REM

<script>
    var clientWidth;
    var px;
    (function (doc, win) {
        var docEl = doc.documentElement,
            resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘,
            recalc = function () {
                clientWidth = docEl.clientWidth;
                
var clientHeight = docEl.clientHeight; px = 100 * (clientWidth / 640); if (!clientWidth) return; docEl.style.fontSize = 100 * (clientWidth / 640) + ‘px‘; }; recalc(); if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc,
false); doc.addEventListener(‘DOMContentLoaded‘, recalc, false); })(document, window); </script>

PX轉REM