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 @   xgqfrms  阅读(758)  评论(3编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2016-07-01 File Viewer Plus is a universal file opener for Windows && FileInfo - The File Extensions Database
2016-07-01 2011-2016 最新 W3C Recommendation
2016-07-01 node.js && npm commands
2016-07-01 gravatars avatar logo All In One
点击右上角即可分享
微信分享提示