Skip to content

Instantly share code, notes, and snippets.

@jordandobson
Last active August 29, 2015 14:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordandobson/d5ec45cb30f4f3ddff45 to your computer and use it in GitHub Desktop.
Save jordandobson/d5ec45cb30f4f3ddff45 to your computer and use it in GitHub Desktop.
Detect Resize and OS / Device Type
$(window).bind('resize', function(){
var size = window.getComputedStyle(document.body,':after').getPropertyValue('content');
if (size.indexOf("break2") !=-1){
// Do stuff for breakpoint 2
} else if (size.indexOf("tablet") !=-1){
// Do stuff for tablet
} else if (size.indexOf("mobile") !=-1){
// Do Mobile Stuff
}
}).trigger('resize');
var b = document.documentElement;
b.setAttribute('data-ua', navigator.userAgent);
b.setAttribute('data-pf', navigator.platform );
html[data-ua *= "Mac OS X 10_"] .yourSelector{
/* Do something for Mac */
}
html[data-ua *= "iPhone OS 7_"] .yourSelector{
/* Do something for iPhone 7 and up */
}
body {
&:after {
content: 'mobile';
display: none;
@include breakpoint($break) {
content: 'tablet';
}
@include breakpoint($break2) {
content: 'break2';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment