Web前端之路Web 前端开发

【Web前端】移动端H5开发遇到的一些坑

2017-08-10  本文已影响335人  mercurygear

textarea

禁止长按出菜单

// 这个css只能对ios设备起作用 
*:not(input):not(textarea) {
  -webkit-user-select: none; /* disable selection/Copy of UIWebView */
  -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */
} 
// 对android设备还需要在body或顶层元素绑定h5引入的contextmenu事件 
window.document.body.addEventListener('contextment', function(e) {
  e.preventDefault();
});

由于用了*选择子,所以a元素也是在内的,这点要注意,如果需要避开a元素的话,就要再加一个not

焦点

虚拟键盘

点击

animation

element remove class;
void element.offsetWidth; // 触发reflow
add class;
  1. 移除后和添加之间有时间间隔
element remove class;
setTimeOut(element add class, 100);
  1. 在setTimeout中执行,浏览器不会优化
setTimeout(() => {
        element remove calss;
        element add class;
}, 100);
上一篇 下一篇

猜你喜欢

热点阅读