Skip to content

Instantly share code, notes, and snippets.

@psgganesh
Forked from jsoverson/device.css
Created April 15, 2016 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psgganesh/d6fd9c01cad23b72d1c123ceacfd48ec to your computer and use it in GitHub Desktop.
Save psgganesh/d6fd9c01cad23b72d1c123ceacfd48ec to your computer and use it in GitHub Desktop.
Quick css hacks to target android/ios
.visible-android {
display:none;
}
.visible-ios {
display:none;
}
.on-device .visible-android, .on-device .visible-ios {
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;
}
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);
@mrcbt
Copy link

mrcbt commented Jun 27, 2018

Hey there, this code prevents scrolling on androids. Any fix for that?

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