Skip to content

Instantly share code, notes, and snippets.

@joshuarule
Last active August 29, 2015 14:06
Show Gist options
  • Save joshuarule/a80ec2ceb797c51d2e57 to your computer and use it in GitHub Desktop.
Save joshuarule/a80ec2ceb797c51d2e57 to your computer and use it in GitHub Desktop.
JS/CSS Breakpoint Detection
body {
&:after {
content: 'mobile';
display: none;
@include breakpoint($break) {
content: 'tablet';
}
@include breakpoint($break2) {
content: 'break2';
}
}
}
$(window).bind('resize', function(){
// grab content from :after pseudo element on body
var size = window.getComputedStyle(document.body,':after').getPropertyValue('content');
if ((size.indexOf("break2") !=-1) {
} else if ((size.indexOf("tablet") !=-1) {
} else if (size.indexOf("mobile") !=-1){
}
}).trigger('resize');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment