























Mezo Istvan does a good job of covering the problem and a solution to it in a blog post on Medium¹.
If you tap on something that has a :hover state but you don’t leave the page then, on a mobile device, there is a chance that :hover state “sticks.” You’ll see this with stuff like jump-links used as tabs or buttons that trigger on-page functionality.
button:hover {
border: 3px solid green; /* might stick! */
}
The solution, or trick, is a new(ish) “CSS4” media query that allows you only to apply styles on devices with hover capability.
@media (hover: hover) {
button:hover {
border: 3px solid green; /* solves sticky problem */
}
}
Your typical touch screen mobile device will fail that media query, the style won’t apply, and you’ll avoid the sticky problem.
Support is solid, so not much worry there.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。