Is it possible to force ignore the :hover pseudoclass for iPhone/iPad users?

Posted by christophercamps on Stack Overflow See other posts from Stack Overflow or by christophercamps
Published on 2010-04-30T01:34:36Z Indexed on 2010/04/30 1:37 UTC
Read the original article Hit count: 331

Filed under:
|

I have some css menus on my site that expand with :hover (without js)

This works in a semi-broken way on iDevices, for example a tap will activate the :hover rule and expand the menu, but then tapping elsewhere doesn't remove the :hover. Also if there is a link inside the element that is :hover'ed, you have to tap twice to activate the link (first tap triggers :hover, second tap triggers link).

I've been able to make things work nicely on iphone by binding the touchstart event.

The problem is that sometimes mobile safari still chooses to trigger the :hover rule from the css instead of my touchstart events!

I know this is the problem because when I disable all the :hover rules manually in the css, mobile safari works great (but regular browsers obviously don't anymore).

Is there a way to dynamically "cancel" :hover rules for certain elements when the user is on mobile safari?

I'm using jQuery.

© Stack Overflow or respective owner

Related posts about mobilesafari

Related posts about iphone-web