css兼容不同设备的问题整理(移动端、PC端、iOS端与android端)

1. h5底部输入框被键盘遮挡问题 

var oHeight = $(document).height(); //浏览器当前的高度
   
   $(window).resize(function(){
 
        if($(document).height() < oHeight){
         
        $("#footer").css("position","static");
    }else{
         
        $("#footer").css("position","absolute");
    }
        
   });

2.不让 Android 手机识别邮箱

<meta content="email=no" name="format-detection" />

3.禁止 iOS 识别长串数字为电话

<meta content="telephone=no" name="format-detection" />

4.禁止 iOS 弹出各种操作窗口

-webkit-touch-callout:none

5.消除 transition 闪屏

-webkit-transform-style: preserve-3d;     /*设置内嵌的元素在 3D 空间如何呈现:保留 3D*/
-webkit-backface-visibility: hidden;      /*(设置进行转换的元素的背面在面对用户时是否可见:隐藏)*/

6.iOS 系统中文输入法输入英文时,字母之间可能会出现一个六分之一空格

可以通过正则去掉      this.value = this.value.replace(/\u2006/g, '');

7.禁止ios和android用户选中文字

-webkit-user-select:none

8.fixed定位缺陷

  • ios下fixed元素容易定位出错,软键盘弹出时,影响fixed元素定位
  • android下fixed表现要比iOS更好,软键盘弹出时,不会影响fixed元素定位
  • ios4下不支持position:fixed
  • 解决方案: 可用iScroll插件解决这个问题

我的原创文章整理:

我的视频应用类原创文章:

猜你喜欢

转载自blog.csdn.net/ffffffff8/article/details/103051746