首页 > 移动平台 > 详细

解决ios不支持按钮:active伪类的方法

时间:2017-12-07 18:11:26      阅读:261      评论:0      收藏:0      [点我收藏+]

 mozilla开发社区上有 :active 不起作用的答案:

[1] By default, Safari Mobile does not use the :active state unless there is a touchstart event handler on the relevant element or on the <body>.

 

在iOS系统的移动设备中,需要在按钮元素或body/html上绑定一个touchstart事件才能激活:active状态。

document.body.addEventListener(‘touchstart‘, function () { //...空函数即可 });  

 

将上述事件监听代码加上后,Safari Mobile上就可以看到按钮按下后的切换效果了。

解决ios不支持按钮:active伪类的方法

原文:http://www.cnblogs.com/saysmy/p/7999947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!