Skip to content

Instantly share code, notes, and snippets.

@ranbena
Created September 21, 2026 11:00
Show Gist options
  • Select an option

  • Save ranbena/702515f1fa01a1da4e4e272eb014b882 to your computer and use it in GitHub Desktop.

Select an option

Save ranbena/702515f1fa01a1da4e4e272eb014b882 to your computer and use it in GitHub Desktop.
Fix for mobile browser "tap on hover"
@mixin hover-no-touch {
@media (hover: hover) and (pointer: fine) and not (any-pointer: coarse) {
@content;
}
}
// (hover: hover) → main pointer can hover
// and (pointer: fine) → that pointer is a cursor, not a finger
// and not (any-pointer: coarse) → nothing coarse is plugged in / built in
.btn {
background: ...;
// only apply hover for non-touch devices
@include hover-no-touch {
&:hover {
background: ...;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment