移动端基本适配事件

<!DOCTYPE HTML>

<html>

<head>

<meta charset=“utf-8”>

<script>

(function(){

  fixwLayou();

  windows.addEventListener('resize',fixwLayou);

  function fixwLayou() {

    const width = window.screen.width;

    const fixW = 750 //移动图宽;

    const scale = width / fixw;

    const meta = document.createElement('meta');

    meta.setAttribute('name','viewport');

    meta.setAttribute('content','width =' fixW+',initial-scale='+scale+',maximum-scale='+scale+',user-scaleable=no');

    document.head.appendChild(meta);

  }

})()

</script>

<style>

</style>

</head>

<body>

</body>

</html>

猜你喜欢

转载自www.cnblogs.com/omiturix/p/10783502.html