ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

javascript懒人屏幕适配

2022-06-23 11:04:49  阅读:71  来源: 互联网

标签:vpWidth scale 适配 javascript 懒人 var targetW document


<!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

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有