移动端的兼容问题和适配问题

174 阅读1分钟

移动端的兼容问题和适配问题

1、ios下input为type=button属性disabled设置true,会出现样式文字和背景消失的问题

解决方案:使用opacity=1设置按钮透明度解决

2、对非可点击元素如(label,span)监听click事件,部分ios版本下不会触发。

解决方案:css增加cursor:pointer就搞定了

移动端字体小于12px使用四周边框或者背景色块,部分安卓文字偏上bug问题。

解决方案:可以使用整体放大1倍(width、height、font-size等等)再使用transform缩放,使用canvas在移动端会模糊也需要这样的解决方案

在安卓机上placeholder文字设置行高会偏上

解决方案:input有placeholder情况下不要设置行高

overflow:scroll,或者auto在iOS上滑动卡顿的问题

解决方案:加入-webkit-overflow-scrolling:touch;

解决iphone下选中input页面自动放大的问题,viewport的user-scalable要设置成no

解决方案:<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover"/>

html5调用安卓或者ios的拨号功能

解决方案:html5提供了自动调用拨号的标签,只要在a标签的href中添加tel:就可以了。

**

<a href="tel:11111111111">点击可拨打电话:11111111111</a>
<a href="tel:4008106999,1034">400-810-69991034</a>
window.location.href = 'tel:11111111111';
<a href="sms:11111111111?body=duanxin">点击可发送短信</a>
<a href="mailto:123456@123456.com?subject=testing&body=youjian">点击可发送短信</a>

禁止 iOS 弹出各种操作窗口

解决方案:-webkit-touch-callout:none

移动端某些情况下input的placeholder会出现文本位置偏上的现象:

解决方案:PC端设置line-height等于height能够对齐,而移动端仍然是偏上,解决是设置line-height:normal