移动端的1px的解决方案

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <!--
            <meta name="viewport" content="width=device-width,initial-scale=.33333,minimum-scale=.33333,maximum-scale=.33333" />
        -->
        <script>
            //获取像素比
       //console.log(window.devicePixelRatio);
            var pixelRatio = 1 / window.devicePixelRatio;
            console.log(pixelRatio);
            //通过js动态设置视口(viewport)
            document.write('<meta name="viewport" content="width=device-width,initial-scale='+pixelRatio+',minimum-scale='+pixelRatio+',maximum-scale='+pixelRatio+'" />');
        </script>
    </head>
    <body>
    </body>
</html>

 

posted @ 2021-03-30 16:35  smil、梵音  阅读(56)  评论(0编辑  收藏  举报