H5 APP 页面移动端适配方案
https://segmentfault.com/a/1190000011586301
https://juejin.im/post/5cbdee71f265da03b57b5866
https://www.jianshu.com/p/2e20f868f385
https://github.com/BoleLee/mobile-web-pagefit
https://segmentfault.com/a/1190000008767416
https://juejin.im/post/5b6503dee51d45191e0d30d2
dpr
let dpr = window.devicePixelRatio;
// device Pixel Ratio
// 设备像素比率
rem
https://www.w3cplus.com/mobile/vw-layout-in-vue.html
vw
vh
rem bug
srcset
js 动态设置根字体
px-to-rem.js
//适配不同尺寸
(function(doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
// default 16px = 1rem; => 1px = 1/16rem (0.0625rem);
docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
// 750px PS & customized 100px = 1rem; => 1px = 1/100rem(0.01rem);
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
Device Metrics
Material Design
https://material.io/tools/devices/