Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS hover not being ignored on touch-screen devices

I've appended a div with a html button:

$('.nav').append('<button class="restart">Restart</button>');

The button has css properties for hover. My problem is that when tapping the button on a touch-screen device, the button retains its hover state until another element is tapped.

Is there any way that the hover property can be ignored when browsing with a touch-screen device?

like image 667
richhastings Avatar asked Dec 18 '12 15:12

richhastings


1 Answers

I came across this exact problem recently, iOS seems to consider the hover psuedo as an additional click, so links will needs clicking twice etc.

If you use modernizr you can apply your :hover psuedos through the .no-touch class which is applied to the html tag.

so:

html a { color:#222; }

html.no-touch a:hover { color:#111; }
like image 199
Wayne Austin Avatar answered Oct 19 '22 05:10

Wayne Austin