Last active
August 29, 2015 14:06
-
-
Save joshuarule/a80ec2ceb797c51d2e57 to your computer and use it in GitHub Desktop.
JS/CSS Breakpoint Detection
This file contains 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'; | |
} | |
} | |
} |
This file contains 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(){ | |
// 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