移动APPmeta、Reset、适配、兼容处理

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="apple-mobile-web-app-capable" content="yes"><!--删除默认的苹果工具栏和菜单栏-->
        <meta name="screen-orientation" content="portrait"><!--qq设置全屏-->
        <meta name="full-screen" content="yes"><!--uc全屏  安卓和 苹果原生浏览器没法强制竖屏和全屏,需js支持  !m=no-->
        <meta name="x5-orientation" content="portrait"><!--x5内核qq,微信 强制横屏或竖屏显示-->
        <meta http-equiv="Cache-Control" content="no-siteapp"><!--控制网页的缓存每次都会访问服务器-->
        <meta name="x5-fullscreen" content="true"><!--qq设置全屏  !m=false-->
        <meta name="format-detection" content="telephone=no, email=no" /><!--禁止识别电话号码和邮箱号码-->
        <meta name="description" content="">
        <meta name="keywords" content="">
        <title>移动端meta标签和默认样式设置</title>
        <!--<script>
        //注意:所适配的设备宽度不能超过目标宽度也就是设计稿宽度哦
            (function(){
                    var w=window.screen.width;  //获取屏幕宽度
                    var targetW=720; //设置每一个页面的缩放比
                    var scale=w/targetW;
                    //动态添加meta标签
                    var meta=document.createElement("meta");
                    meta.name="viewport";
                    meta.content="initial-scale="+scale+",minimum-scale="+scale+",maximum-scale="+scale+",user-scalable=no"
                    //console.log(scale)
                    document.head.appendChild(meta);
            })()
        <script>-->
        <!--<script>
            window.addEventListener(('orientationchange' in window ? 'orientationchange' : 'resize'), (function() {
                function resize() {
                            
                }
                resize();
                return resize;
        })(), false);
        </script>-->
        <script>
            /*
             touch事件的时候,手机自己是会有滚动的功能的你用到touch事件,就会触发手机上面的默认事件,页面就会出问题,因此阻止掉浏览器默认事件,
             */
            document.addEventListener('touchstart',function(ev){
                ev.preventDefault();//阻止浏览器的默认行为
            })
        </script>
        <script>
            var pixelRatio = 1/window.devicePixelRatio;
            document.write('<meta name="viewport" content="width=device-width,initial-scale='+pixelRatio+',minimum-scale='+pixelRatio+',maximum-scale='+pixelRatio+',user-scalable=no" />');
            var  html = document.getElementsByTagName('html')[0];
            var pageWidth=html.getBoundingClientRect().width;
            html.style.fontSize=pageWidth/16+'px';
            
            
        </script>
        <style>
            body, h1, h2, h3, h4, h5, h6, p, dl, dd { margin: 0; }
            ul, ol { margin: 0; padding: 0; list-style: none; }
            img { border: none; vertical-align: top; }
            a { text-decoration: none; }
            
            
            body {
                font-family: helvetica;/*英文字体*/
            }
            body * {
                -webkit-text-size-adjust: 100%;/*禁止用户修改字体大小,部分横竖屏切换字体大小缩放*/
                -webkit-user-select: none;/*禁止选中文字,安卓部分机型没效果,弹出菜单js*/
            }
            a,
            input,
            button {
                -webkit-tap-highlight-color: rgba(0, 0, 0, 0);/*清除点击阴影*/
            }
            input,
            button {
                -webkit-appearance: none;/*清除ios按钮圆角*/
                border-radius: 0;
            }html

    html{ios

    width:100%;web

    height:100%;浏览器

    overflow:hidden;缓存

  }服务器

         body{微信

    width:100%;app

    height:100%;工具

    overflow:auto;字体

  }

============

<!--ios下 bodyovflow:auto失效 200%仍是会出现横向滚动条,解决办法再包一层div 相对了增长的div进行定位-->        html{            height: 100%;            overflow: hidden;/*去掉页面默认滚动条*/                                }        body{            margin: 0;            height: 动态计算的;            overflow: hidden;            position: relative;        }        .wrap{            height: 100%;            overflow: auto; /*此时页面的滚动条是body的*/        }        </style>    </head>    <body>        <script>            var h= document.documentElement.clientHeight;            document.body.style.height=h+'px';        </script>        <a href="tel:18569032656">请拨打电话:18569032656</a>        <a href="mailto:yuanbo@yuanbo.com">请发送邮件:yuanbo@yuanbo.com</a>    </body></html>

相关文章
相关标签/搜索