xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

H5 APP 页面移动端适配方案

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

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/


posted @ 2019-07-01 10:16  xgqfrms  阅读(756)  评论(3编辑  收藏  举报