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

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

问题描述

在iPhone / iPad / iPod上的Webkit中,为< a> 标记指定样式的活动伪类不会在您点击元件。我如何得到这个触发?示例代码:

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.

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

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