-
-
Save elpuas/2366d9f36191f1ce6acfd7f33869187e to your computer and use it in GitHub Desktop.
Quick css hacks to target android/ios
This file contains hidden or 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
.visible-android { | |
display:none; | |
} | |
.visible-ios { | |
display:none; | |
} | |
.on-device .visible-android, .on-device .visible-android { | |
display:inherit; | |
} | |
.device-ios .visible-android { | |
display:none !important; | |
} | |
.device-ios .hidden-ios { | |
display:none !important; | |
} | |
.device-android .hidden-android { | |
display:none !important; | |
} | |
.device-android .visible-ios { | |
display:none !important; | |
} |
This file contains hidden or 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
var classNames = []; | |
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/i)) classNames.push('device-ios'); | |
if (navigator.userAgent.match(/android/i)) classNames.push('device-android'); | |
var html = document.getElementsByTagName('html')[0]; | |
if (classNames.length) classNames.push('on-device'); | |
if (html.classList) html.classList.add.apply(html.classList, classNames); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment