验证分辨路的方式
! function (userAgent) {
var screen_w = parseInt(window.screen.width),
scale = screen_w / 1080;
if (/Android (\d+\.\d+)/.test(userAgent)) {var version = parseFloat(RegExp.$1);
document.write(version > 2.3 ? '<meta name="viewport" content="width=1080, minimum-scale=' + scale + ', maximum-scale=' + scale + ', target-densitydpi=device-dpi">' : '<meta name="viewport" content="width=1080, target-densitydpi=device-dpi">');
} else {
document.write('<meta name="viewport" content="width=1080, minimum-scale=' + scale + ', maximum-scale=' + scale + ', user-scalable=no, target-densitydpi=device-dpi">');
}
}(navigator.userAgent);
一般可以考虑rem 但是还可以这样,ui 按照多少尺寸的设计,就用现在的屏幕大小除以 尺寸大小,然后设置meta。 就可以按照设计图上写的px来布局,轻松自在。。。兼容性还要更强。。