I want to fix the hover effect on iOS ( change to touch event ) but I dont have any idea . Let me explain this . You have a text in your page :
<div class="mm">hello world</div>
With style :
.mm { color:#000; padding:15px; }
.mm:hover { background:#ddd; }
Ok , in dekstop if you put your mouse over the text you get a #ddd background , right ? But in iOS if you touch the text you get nothing but if you tap it it gets a ugly and sticky #ddd background which is not nice and I want the user get the hover effect when he touch that text ( something like touchevent I think ) . But I see some websites fixed that like freemyappps.com or ( please check this site ->D4F on your ios device and touch something to see the hover effect like eating a cake :) ) But how these sites fixed that ? How can fix like them ? Thanks
Here is a basic, successful use of javascript hover on ios that I made:
Note: I used jQuery, which is hopefully ok for you.
JavaScript:
CSS:
HTML:
I"m not sure if this will have a huge impact on performance but this has done the trick for me in the past:
I successfully used
which was documented on http://fofwebdesign.co.uk/template/_testing/ios-sticky-hover-fix.htm
so a variation of Andrew M answer.
The hover pseudo class only functions on iOS when applied to a link tag. They do that because there is no hover on a touch device reall. It acts more like the active class. So they can't have one unless its a link going somewhere for usability reasons. Change your div to a link tag and you will have no problem.
In response to Dan (https://stackoverflow.com/a/20048559/4298604), I would recommend a slightly altered version.
Adding "void(0)" helps to obtain the undefined primitive value, as opposed to "".
Some people don't know about this. You can apply it on
div:hover
and working on iPhone .Add the following css to the element with
:hover
effect