Skip to content

Instantly share code, notes, and snippets.

@nikoskip
Created July 31, 2014 15:41
Show Gist options
  • Save nikoskip/f6ee7b8191945b97adaf to your computer and use it in GitHub Desktop.
Save nikoskip/f6ee7b8191945b97adaf to your computer and use it in GitHub Desktop.
Detect touch devices
// It will add the appropriate class to <html> node
var root = document.documentElement;
if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
root.className += ' touch';
} else {
root.className += ' no-touch';
}
@baamenabar
Copy link

Cabe comentar que esto se recomienda solo en combinación de mediaqueries para viewports anchos. Y siempre con la idea de mobile-first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment