1. 简单版:
s = window.screen.width / 1920; document.body.style.zoom = s;
2. 当开发前端页面在分辨率1920的情况下,需要切换到小屏,有种方法是可以对屏幕比例进行缩放,通过css3属性transform可以自适应屏幕分辨率大小
var s; function resize() { s = window.screen.width / 1920; document.body.style.transformOrigin = '0 0'; document.body.style.transform = 'scale(' + s + ',' + s + ')'; document.body.style.width = window.innerWidth / s + 'px'; document.body.style.height = window.innerHeight / s + 'px'; } window.onresize = function () { resize(); } resize();
标签:body,style,缩放,分辨率,js,window,document,页面 From: https://www.cnblogs.com/sishahu/p/17967483