您当前的位置: 首页 >  Java

漏刻有时

暂无认证

  • 0浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

javascript封装函数:解决win10缩放和布局推荐125%网页无法自适应的解决方案

漏刻有时 发布时间:2021-04-21 20:52:53 ,浏览量:0

说明: 自能解决部分适应情况,如果要完整解决该缩放和布局,仍需适配。

在这里插入图片描述

//函数封装
function detectZoom () {
    let ratio = 0,
        screen = window.screen,
        ua = navigator.userAgent.toLowerCase();
    if (window.devicePixelRatio !== undefined) {
        ratio = window.devicePixelRatio;
    } else if (~ua.indexOf('msie')) {
        if (screen.deviceXDPI && screen.logicalXDPI) {
            ratio = screen.deviceXDPI / screen.logicalXDPI;
        }
    } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
        ratio = window.outerWidth / window.innerWidth;
    }
    if (ratio) {
        ratio = Math.round(ratio * 100);
    }
    return ratio;
}

//页面自动加载;
window.onload = function(){
    handleScreen();
}

lockdatav Done!

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.1333s