zoukankan      html  css  js  c++  java
  • 移动端配置

    • 在移动端,低端无定制的需求,都可以用这个完美视口完成

      • <meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=0,maximum-scale=1.0"/>
        <!DOCTYPE html>
        <html lang="zh">
        
        <head>
            <meta charset="UTF-8">
            <title>rem phone test</title>
            <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
            <style>
                html {
                    height: 100%;
                     100%;
                    font-family: 'Heiti SC', 'Microsoft YaHei';
                    font-size: 20px;
                    overflow: hidden;
                    outline: 0;
                    -webkit-text-size-adjust:none;
                }
                body {
                    height: 100%;
                    margin: 0;
                    overflow: hidden;
                    -webkit-user-select: none;
                    position: relative;
                }
                header,
                footer {
                     100%;
                    line-height: 1.5rem;
                    font-size: 1rem;
                    color: #000;
                    border: 1px solid #ccc;
                    text-align: center;
                    background-color: #ccc;
                }
                .bd {
                    margin-top: 1rem;
                    margin-bottom: .5rem;
                    margin-right: -.5rem;
                    font-size: 0;
                }
                .box {
                     5rem;
                    height: 5rem;
                    display: inline-block;
                    margin-right:.5rem;
                    margin-bottom: .5rem;
                }
                .blue-box {
                    background-color: #06c;
                }
                .org-box {
                    background-color: #1fc195;
                }
            </style>
            
        </head>
        
        <body>
        
            <header>我是头部</header>
        
        
            <div class="bd">
                <div class="box blue-box"></div>
                <div class="box org-box"></div>
                <div class="box blue-box"></div>
                <div class="box org-box"></div>
                <div class="box blue-box"></div>
                <div class="box org-box"></div>
            </div>
        
        
            <footer>我是页脚</footer>
            
            <script>

          //不管在任何分辨率下,页面的排版都是按照等比例进行切换,并且布局没有乱。通过一段js根据浏览器当前的分辨率改变font-size的值,就简单的实现了上面的效果,页面的所有元素都不需要进行任何改变。 (function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function () { var clientWidth = docEl.clientWidth; if (!clientWidth) return; docEl.style.fontSize = 20 * (clientWidth / 320) + 'px'; }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); })(document, window); </script> </body> </html>
        在做web app都会先统计自己网站有哪些主流的屏幕设备,然后去针对那些设备去做media query设置也可以实现适配,例如下面这样:
        
        html {
            font-size : 20px;
        }
        @media only screen and (min- 401px){
            html {
                font-size: 25px !important;
            }
        }
        @media only screen and (min- 428px){
            html {
                font-size: 26.75px !important;
            }
        }
        @media only screen and (min- 481px){
            html {
                font-size: 30px !important; 
            }
        }
        @media only screen and (min- 569px){
            html {
                font-size: 35px !important; 
            }
        }
        @media only screen and (min- 641px){
            html {
                font-size: 40px !important; 
            }
        }
        
            上面的做的设置当然是不能所有设备全适配,但是用JS是可以实现全适配。具体用哪个就要根据自己的实际工作场景去定了。
  • 相关阅读:
    python的类基础
    python导入模块
    python常用的内置函数
    python基础一数据类型之集合
    python函数-匿名函数
    python的函数(三)
    python的函数(二)
    python的函数(一)
    BZOJ4104:[Thu Summer Camp 2015]解密运算——题解
    BZOJ4033:[HAOI2015]树上染色——题解
  • 原文地址:https://www.cnblogs.com/wenb/p/5968882.html
Copyright © 2011-2022 走看看