Created
January 15, 2018 07:40
-
-
Save CaptainLiao/4e0d8c86f5125ff0e5b73d76c39e257b to your computer and use it in GitHub Desktop.
This file contains 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
(function() { | |
window.onresize = function() { | |
setRootFontSize(); | |
}; | |
setRootFontSize(); | |
function setRootFontSize() { | |
var el = document.documentElement; | |
var w = el.clientWidth; | |
// 最大按6Plus,最小按240,因为小于12px可能就有问题了 | |
if (w > 414) { w = 414; } else if (w < 240) { w = 240; } | |
el.style.fontSize = w / 20 + 'px'; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment