:active 伪类在移动 safari 中不起作用 [英] :active pseudo-class doesn't work in mobile safari

查看:24
本文介绍了:active 伪类在移动 safari 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iPhone/iPad/iPod 上的 Webkit 中,为 <a> 标签指定 :active 伪类的样式不会在您点击元素时触发.我怎样才能触发这个?示例代码:

In Webkit on iPhone/iPad/iPod, specifying styling for an :active pseudo-class for an <a> tag doesn't trigger when you tap on the element. How can I get this to trigger? Example code:

<style> 
a:active { 
    background-color: red;
}
</style>
<!-- snip -->
<a href="#">Click me</a>

推荐答案

<body ontouchstart="">
    ...
</body>

只应用一次,而不是每个按钮元素似乎都修复了页面上的所有按钮.或者,您可以使用这个名为Fastclick"的小型 JS 库.它可以加速触摸设备上的点击事件,并能解决这个问题.

Applied just once, as opposed to every button element seemed to fix all buttons on the page. Alternatively you could use this small JS library called 'Fastclick'. It speed up click events on touch devices and takes care of this issue too.

这篇关于:active 伪类在移动 safari 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆