Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix CSS hover on iPhone/iPad/iPod

Tags:

css

ios

hover

touch

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

like image 933
user2627442 Avatar asked Aug 04 '13 20:08

user2627442


People also ask

Does CSS hover work on mobile devices?

Hover effects inform users what they can interact with by providing visual feedback on buttons. But there's a problem — hover effects are for desktop apps, not mobile apps. There are no mouse devices on mobile, so users don't have the luxury of using hover effects.

Does hover work on iOS?

The HOVER mobile app is available on all Apple mobile devices on iOS 11.1 or newer and most Android mobile devices on Android 8.0 or newer. You can capture photos with a smartphone or tablet.

How do you simulate hover on touch devices?

To answer your main question: “How do I simulate a hover with a touch in touch enabled browsers?” Simply allow 'clicking' the element (by tapping the screen), and then trigger the hover event using JavaScript. var p = document.


1 Answers

Add onclick="" to anything you wish iOS to recognise as an element with a hover.

<div onclick="">Click Me!</div> 
like image 142
Dan Morris Avatar answered Oct 08 '22 12:10

Dan Morris