赣州建站资讯网

为消费者提供更优质的体验

禁止页面放大代码

禁止页面放大代码

<script>
                        const dpr = window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI;
                        const preferWidth = 1750 //预期值
                        let zoom = 1
                        if (dpr > 1) { // 用户有放大,我们再做缩放
                          const screenWidth = window.screen.width // 我们是针对屏幕进行缩放的,不是针对浏览器
                          if (screenWidth < preferWidth) { // 屏幕小于预期值才执行
                            zoom = screenWidth / preferWidth // 得到缩放倍数
                            document.documentElement.style.zoom = zoom
                          }
                        }
                        //设置css变量值
                        document.documentElement.style.setProperty('--zoom', zoom)
                        document.documentElement.style.setProperty('--full-height', window.innerHeight)
                </script>
                <style>
                        html {
                           min-height: calc(100vh / var(--zoom));
                            calc(100vw / var(--zoom));
                           height: calc(100vh / var(--zoom));
                         }
                </style>



- END -
声明:文字图片等素材除标明原创外均来源于网络,如有侵权,请及时告知我们,我们将在最短的时间内删除!

相关推荐

微信公众平台:圆狐创意

关注圆狐创意微信公众平台浏览最新资讯

更多媒体及商务合作

QQ:295939675   或  至电:198-6662-0460