Skip to content

Instantly share code, notes, and snippets.

@userkang
Created January 4, 2019 03:49
Show Gist options
  • Save userkang/b55676aea5f8340669262c2f8bea7a10 to your computer and use it in GitHub Desktop.
Save userkang/b55676aea5f8340669262c2f8bea7a10 to your computer and use it in GitHub Desktop.
rem缩放js
// 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