Skip to content

Instantly share code, notes, and snippets.

@ztrehagem
Created May 13, 2019 01:52
Show Gist options
  • Save ztrehagem/aaacf22748aef79e7bf50618e1a724d7 to your computer and use it in GitHub Desktop.
Save ztrehagem/aaacf22748aef79e7bf50618e1a724d7 to your computer and use it in GitHub Desktop.
disabling hover styles on touch/mobile devices
hover() {
/body:not(.__device-touchdevice) {selector()}:hover {
{block};
}
}
if ('ontouchstart' in (document.documentElement || {})) {
document.body.classList.add('__device-touchdevice');
}
a {
foo: 100;
}
body:not(.__device-touchdevice) a:hover {
bar: 200;
}
body:not(.__device-touchdevice) a:hover img {
baz: 300;
}
a {
foo: 100;
+hover() {
bar: 200;
img {
baz: 300;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment