Created
July 31, 2014 15:41
-
-
Save nikoskip/f6ee7b8191945b97adaf to your computer and use it in GitHub Desktop.
Detect touch devices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cabe comentar que esto se recomienda solo en combinación de mediaqueries para
viewports
anchos. Y siempre con la idea de mobile-first.