1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| function setSize() { let screenWidth = document.documentElement.clientWidth let screenHeight = document.documentElement.clientHeight let scaled = 1920 / 1040 let currentFontSize = 12 if (scaled > screenWidth / screenHeight) { currentFontSize = screenWidth / 1920 } else { currentFontSize = screenHeight / 1040 }
document.documentElement.style.fontSize = currentFontSize + 'px' }
(function (w) { w.addEventListener('resize', setSize) w.addEventListener('pageShow', setSize) w.addEventListener('DOMContentLoaded', setSize) })(window) setSize()
|