I'm trying to prevent the hover effect from firing when I click on an element on my phone's browser. It seems everyone recommends to use the media query for hover to solve this.
I don't understand because this doesn't seem to do anything for me. I'm using the latest Chrome on my new Android phone and when I click on the element the hover effect still runs and the red background gets stuck there.
That is, clicking the following element in this code on my phone causes the red background to get stuck before I click elsewhere to make it go away.
.test {
background-color: #ddd;
padding: 10px;
}
@media (hover:hover) {
.test:hover {
background-color: #ff0000;
}
}
<div class="test">
hover me
</div>
Does anyone know why this is happening? How can I prevent sticky hovers from occurring on mobile?