编程语言
首页 > 编程语言> > javascript懒人屏幕适配

javascript懒人屏幕适配

作者:互联网

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //根据基准屏幕宽度等比例缩放页面(适配不同设备宽度)
        (function () {
            var targetW = 1280
            var vpWidth = document.documentElement.clientHeight
            var scale = vpWidth / targetW
            document.querySelector("meta[name=viewport]").content = "initial-scale=" + scale
        })
    </script>
</head>

<body>

</body>

</html>

标签:vpWidth,scale,适配,javascript,懒人,var,targetW,document
来源: https://www.cnblogs.com/LiZiheng/p/16404282.html