Skip to content

Instantly share code, notes, and snippets.

@simonqian
Created March 2, 2019 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonqian/e7fee39c5fe3d3d9759aa72aa5365a0a to your computer and use it in GitHub Desktop.
Save simonqian/e7fee39c5fe3d3d9759aa72aa5365a0a to your computer and use it in GitHub Desktop.
  window.addEventListener('resize', resizeWidth)
 
  function resizeWidth() {
    console.log('resize')
    const body = document.getElementsByTagName('body')[0]
    var heRatio = window.innerHeight / 1080
    var widRatio = window.innerWidth / 1920
    var ratio = widRatio + ',' + heRatio
    body.style.transform = 'scale(' + ratio + ')'
    body.style.transformOrigin = 'left top'
    body.style.backgroundSize = '100% 100%'
    body.style.backgroundPosition = 'left top'
    body.style.width = '1920px'
    body.style.height = '1080px'
    body.style.backgroundColor = '#021b2d'
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment