WEB前端开发-移动端兼容性问题汇总

最近更新时间:2018年4月9日16:50:05html

《个人博客地图》
前端

    做为一名专业的web前端开发工程师,必须时刻谨记本身的使命和价值,可以独立处理平常开发任务中的常规问题,而且善于总结和积累实践经验。android

一、移动端开发须要加入的代码web

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">  
<meta name="viewport" content="initial-scale=1, 
 user-scalable=no",windows

maximum-scale=1, minimum-scale=1>
iphone

二、判断移动端仍是PC端flex

function browserRedirect() {
                var ua= navigator.userAgent.toLowerCase();
                var ipad= ua.match(/ipad/i) == "ipad";
                var iphone= ua.match(/iphone os/i) == "iphone os";
ui

                var mid= ua.match(/midp/i) == "midp";spa

//midp,即Mobile Internet Device pad,一种新的“比智能电话大,比笔记本小”的互联网终端。.net

                var uc7= ua.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
                var uc= ua.match(/ucweb/i) == "ucweb";
                var android= ua.match(/android/i) == "android";
                var ce= ua.match(/windows ce/i) == "windows ce";
                var mobile= ua.match(/windows mobile/i) == "windows mobile";
                if (ipad|| iphone|| mid|| uc7|| uc || android|| ce|| mobile) {
                    //跳转移动端页面
                    window.location.href="http://www.wanshaobo.com/mobile/index.html";
                } else {
                    //跳转pc端页面
                    window.location.href="http://www.wanshaobo.com/index.html";
                }

            }

三、手机查看本地调试的html项目


Android端和IOS端

一、1px边框问题

#ele:before{
            content:'';
            position: absolute;
            top: 0;
            left: 0;
            border: 1px solid #ccc;
            width: 200%;
            height: 200%;
            box-sizing:border-box;
            -webkit-box-sizing:border-box;
            -webkit-transform: scale(0.5);
            transform: scale(0.5);
            -webkit-transform-origin: left top;
            transform-origin: left top;
}

二、在移动端图片上传图片 使用accept="image/*" multiple,兼容低端机的问题

三、使用 lib-flexible 实现H5页面适配


Android端


IOS端

一、input标签,设置type=button属性,disabled设置true,会出现样式文字和背景异常问题

解决方案:使用opacity=1

二、有时对非可点击元素如(label,span)添加单机监听事件,不会触发

解决方案:修改样式,cursor:pointer

三、使用webview时,页面滚动卡顿

解决方案:对webview设置更低的“减速率”

self.webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;