$(function () {
resizing();
})
function resizing(){
const m = obtainZoom();
document.body.style.zoom = 100/Number(m);
if(Number(m) == 125){
var bodySize = Number(m)+5+"%";
$("body").css("background-size",bodySize+""+bodySize);
}else{
var bodySize=Number(m)+"%";
$("body").css("background-size",bodySize+""+bodySize);
}
}
function obtainZoom () {
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;
}
web网页适配windows10电脑的缩放与布局的设置
最新推荐文章于 2022-08-23 10:38:20 发布
关键词由CSDN通过智能技术生成