Jesse Rusak Jesse Rusak - 7 months ago 42
CSS Question

:active pseudo-class doesn't work in mobile safari

In Webkit on iPhone/iPad/iPod, specifying styling for an :active pseudo-class for an

tag doesn't trigger when you tap on the element. How can I get this to trigger? Example code:

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

<body ontouchstart="">

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.