前端(移动端)

移动端

在js中那个750是效果图的宽度,100是px 这里我们用100px像素转换成rem比较方便。在做移动端的时候一般用flex盒子,这个比较方便。

<script>           

     window.onload = function(){

var html = document.querySelector("html");

    html.style.fontSize = html.offsetWidth / 750 * 100 + "px";

     addEventListener("resize",function(){

              html.style.fontSize = html.offsetWidth / 750 * 100 + "px";

     },false);

}

</script>

扫描二维码关注公众号,回复: 2800164 查看本文章

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<meta name="format-detection" content="telephone=no" />

<meta name="format-detection" content="email=no" />

<meta name="apple-mobile-web-app-capable" content="yes" />

<meta name="apple-mobile-web-app-status-bar-style" content="black" />

 

猜你喜欢

转载自blog.csdn.net/asedasdad/article/details/81356112