Last active
August 29, 2015 14:06
-
-
Save jordandobson/d5ec45cb30f4f3ddff45 to your computer and use it in GitHub Desktop.
Detect Resize and OS / Device Type
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
$(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'); |
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 b = document.documentElement; | |
b.setAttribute('data-ua', navigator.userAgent); | |
b.setAttribute('data-pf', navigator.platform ); |
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
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 */ | |
} |
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
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