移动端rem距离单位的使用
发布日期:2021-05-13 01:00:20 浏览次数:14 分类:博客文章

本文共 1631 字,大约阅读时间需要 5 分钟。

������������������������������������������������������������������������������������������������������������������������������px������������������������������������������������������rem���������������������������������������������������������������������������������������������������������������������������rem������������������

rem���������������������������������������������������������������������������������������������������������������rem���px������������������������

1
rem = 100
px

���UI���������������������������750px���������������������������������������������������������������������750px���������������rem���������������������������������������

(function(doc, win) {  var docEl = doc.documentElement,  resizeEvt = "orientationchange" in window ? "orientationchange" : "resize",  recalc = function() {    var clientWidth = docEl.clientWidth;    if (!clientWidth) return;    if (clientWidth > 750) {      docEl.style.fontSize = "100px"; // ������������������750������������������100px    } else {      docEl.style.fontSize = 100 * (clientWidth / 750) + "px";    }    /*     * 100 -> html,body {  font-size:100px; }     * 750 -> ��������� iPhone6 ��������������� ������750px ������������     * ���������������������������������������     */  };if (!doc.addEventListener) return;    win.addEventListener(resizeEvt, recalc, false);    doc.addEventListener("DOMContentLoaded", recalc, false);})(document, window);

������������������������window���resize���������������������������������������������������������������������������������rem������������������������������������������������������������������������������������

上一篇:告别组件之教你使用原生js和css写移动端轮播图
下一篇:LeetCode 对称二叉树

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月30日 10时00分21秒