Last active
August 28, 2021 19:41
-
-
Save viclm/1de60f42e3029af08f4182a615f97462 to your computer and use it in GitHub Desktop.
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
(function () { | |
var scale = 1 / window.devicePixelRatio; | |
document.querySelector('meta[name=viewport]').setAttribute('content', 'width=device-width,initial-scale='+scale+',maximum-scale='+scale+',minimum-scale='+scale+',user-scalable=no'); | |
var rangingRem = document.createElement('div'); | |
rangingRem.style.cssText = 'width:1rem;'; | |
document.head.appendChild(rangingRem); | |
var defaultFontSize = parseFloat(getComputedStyle(rangingRem).getPropertyValue('width'), 10); | |
document.head.removeChild(rangingRem); | |
var uiWidth = parseInt(document.querySelector('meta[itemprop=uw]').getAttribute('content'), 10); | |
document.documentElement.style.fontSize = document.documentElement.clientWidth * 100 / uiWidth / defaultFontSize * 100 + '%'; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment