I have created a carousel with a previous and a next button that are always visible. These buttons have a hover state, they turn blue. On touch devices, like iPad, the hover state is sticky, so the button stays blue after tapping it. I don't want that.
I could add a
no-hover
classontouchend
for each button, and make
my CSS like this:button:not(.no-hover):hover { background-color:
but that's probably quite bad for performance, and doesn't
blue; }
handle devices like the Chromebook Pixel (which has both a
touchscreen and a mouse) correctly.I could add a
touch
class to thedocumentElement
and make my CSS
like this:html:not(.touch) button:hover { background-color: blue;
But that also doesn't work right on devices with both touch and a
}
mouse.
What I would prefer is removing the hover state ontouchend
. But it doesn't seem like that is possible. Focusing another element doesn't remove the hover state. Tapping another element manually does, but I can't seem to trigger that in JavaScript.
All the solutions I have found seem imperfect. Is there a perfect solution?