H5 APP 页面移动端适配方案 h5,app,移动端,适配,方案,css,media query, rem, bug,



H5 APP 页面移动端适配方案

H5 APP 页面移动端适配方案_适配

​https://www.jianshu.com/p/2e20f868f385​

​https://github.com/BoleLee/mobile-web-pagefit​

H5 APP 页面移动端适配方案_适配_02

H5 APP 页面移动端适配方案_H5_03

H5 APP 页面移动端适配方案_适配_04

H5 APP 页面移动端适配方案_H5_05

H5 APP 页面移动端适配方案_H5_06

H5 APP 页面移动端适配方案_H5_07

dpr


let dpr = window.devicePixelRatio;

// device Pixel Ratio
// 设备像素比率


H5 APP 页面移动端适配方案_H5_08

rem

​https://www.w3cplus.com/mobile/vw-layout-in-vue.html​


vw
vh


rem bug

H5 APP 页面移动端适配方案_移动端_09

srcset

​https://responsiveimages.org/​

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/​