美文网首页
移动端布局rem解决方案

移动端布局rem解决方案

作者: 独孤久见 | 来源:发表于2018-02-25 18:22 被阅读0次

    移动端布局rem解决方案

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
        <meta content="yes" name="apple-mobile-web-app-capable">
        <meta content="black" name="apple-mobile-web-app-status-bar-style">
        <meta content="telephone=no" name="format-detection">
        <meta content="email=no" name="format-detection">
        <script>
            (function (doc, win) {
                var docEl = doc.documentElement,
                        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                        recalc = function () {
                            var clientWidth = docEl.clientWidth;
                            if (!clientWidth) return;
                            if (clientWidth >= 640) {
                                docEl.style.fontSize = '100px';
                            } else {
                                docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
                            }
                        };
                if (!doc.addEventListener) return;
                win.addEventListener(resizeEvt, recalc, false);
                doc.addEventListener('DOMContentLoaded', recalc, false);
            })(document, window);
        </script>
        <title>Title</title>
        <style media="screen">
          html{-webkit-overflow-scrolling:touch;overflow-scrolling:touch;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-webkit-user-select:none;-ms-user-select:none}
          body,button,input,select,textarea{font-family:TrebuchetMS,Rotobo,"Microsoft YaHei",sans-serif}
          body,dd,dl,dt,form,h1,h2,h3,h4,h5,h6,html,li,ol,p,select,ul{margin:0;padding:0}
          .box{height: 1rem;border:0.1rem solid #ddd;box-sizing:border-box;width:100%;}
          .left{float: left;font-size: 0.3rem;}
          .right{float: right;font-size: 0.3rem;}
        </style>
    </head>
    <body>
    <div class="box">
      <div class="left">
        左边
      </div>
      <div class="right">
        右边
      </div>
    </div>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:移动端布局rem解决方案

          本文链接:https://www.haomeiwen.com/subject/iagrxftx.html