Created
January 4, 2019 03:49
-
-
Save userkang/b55676aea5f8340669262c2f8bea7a10 to your computer and use it in GitHub Desktop.
rem缩放js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rem基准计算和限宽 | |
(function(){ | |
function refreshRem() { | |
document.documentElement.style.fontSize = (document.documentElement.clientWidth > 720 ? 720 : document.documentElement.clientWidth) / 18 + "px" | |
} | |
var tid = null; | |
window.addEventListener("resize", function() { | |
clearTimeout(tid); | |
tid = setTimeout(refreshRem, 0); | |
}, false); | |
refreshRem(); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment