Last active
August 29, 2015 13:57
-
-
Save jruck/9742401 to your computer and use it in GitHub Desktop.
conditionally loading content based on CSS breakpoints
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
/* CSS for setting variable within breakpoint */ | |
@media all and (min-width: 45em) { | |
body:after { | |
content: 'widescreen'; | |
display: none; | |
} | |
} | |
/* JS for fetching variable */ | |
var size = window.getComputedStyle(document.body,':after').getPropertyValue('content'); | |
/* JS for doing stuff if breakpoint reached */ | |
if (size == 'widescreen') { | |
// Load some more content. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment