zoukankan      html  css  js  c++  java
  • rem手机端适配

    <script>
    document.documentElement.style.fontSize=document.documentElement.clientWidth*100/750+"px";
    window.addEventListener("resize",function(){
    document.documentElement.style.fontSize=document.documentElement.clientWidth*100/750+"px";
    },false)
    </script>


    <script>
    //因绝对定位+margin百分比定位在UC中有BUG,翻屏页面建议使用rem单位
    (function (doc, win) {
    var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
    var clientWidth = docEl.clientWidth;
    if (clientWidth < 375) {
    docEl.style.fontSize = 50 + 'px'
    } else if (clientWidth > 750) {
    docEl.style.fontSize = 100 + 'px'
    } else {
    docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
    }
    };
    recalc();
    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    })(document, window);
    </script>
  • 相关阅读:
    LeetCode 12. Integer to Roman
    个人博客09
    个人博客08
    人机交互之我的输入法
    学习进度条(第六周)
    《梦断代码》阅读笔记02
    个人博客07
    学习进度条(第五周)
    个人博客06
    个人博客05
  • 原文地址:https://www.cnblogs.com/wanan-01/p/7716335.html
Copyright © 2011-2022 走看看