/*16:9缩放*/ window.addEventListener('load', adaptation); window.addEventListener('resize', adaptation); function adaptation() { let el = document.getElementById('app') console.log({obj:el}) const win_w = window.innerWidth; const win_h = window.innerHeight; const app_w = el.clientWidth; const app_h = el.clientHeight; const scale_w = win_w / app_w const sclae_h = win_h / app_h const left = -(app_w - win_w) / 2 const top = -(app_h - win_h) / 2 el.setAttribute('style', 'transform: scale(' + scale_w + ',' + sclae_h + ');left:' + left + 'px;top:' + top + 'px;'); }