移动端常见问题总结

qq浏览器

x5内核浏览器强制横屏或竖屏显示<meta name="x5-orientation" content="portrait|landscape" />

全屏显示<meta name="x5-fullscreen" content="true" />


UC浏览器

强制横屏或竖屏显示<meta name="screen-orientation" content="portrait|landscape" />

全屏显示<meta name="full-screen" content="yes" />


IOS10 meta user-scalable=no 无效,body或html overflow: hidden无效

使用阻止touchstart事件来模拟

document.addEventListener('touchstart',function(e){e.preventDefault();})

它还可以:

1. 禁止长按选中文字、选中图片、弹出系统菜单

2. 禁止系统滚动条、组织橡皮筋效果(下拉回弹效果)

3. 解决点透问题

4. 也阻止了input等元素获取焦点,可以通过手动为这些元素绑定touchstart阻止冒泡来解决

$('input').addEventListener('touchstart',function(e){e.stopPropogation();});


常见设置

禁止识别电话号码或邮箱<meta name="format-detection" content="telephone=no,email=no" />

允许识别电话号码<a href="tel:13524565456">13524565456</a>

允许识别邮件<a href="mailto:邮箱地址">邮箱地址</a>


设置超链接点击时背景色a,input,button{-webkit-tap-highlight-color: rgba(0,0,0,0)}


去除按钮默认圆角: input,button{-webkit-appearance:none;border-radius:0;}


禁止用户修改字体大小: body *{-webkit-text-size-adjust: 100%;}


禁止用户选中文字设置:  -webkit-user-select: none;


fontboosting: https://zhidao.baidu.com/question/1514399955942799500.html


固定定位fixed在页面滑动的时候抖动问题: 

html设置溢出隐藏,顶部和底部绝对定位,然后让main出滚动条,margin-top: header高度,margin-bottom: footer高度,这样就不需要fixed

<body>

<header></header>

<main></main>

<footer></footer>

</body>


ios safri为body设置了溢出隐藏,依然可以横向拖动:

为body设置相对定位,为wrap设置overflow: auto

body{

height: 100%;

margin: 0;

overflow: hidden;

position: relative;

}

#wrap{

height: 100%;

overflow: auto;

}


<body>

<div id="wrap">

<header></header>

<main></main>

<footer></footer>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值