Created
August 13, 2015 13:55
-
-
Save wtfaremyinitials/eade9ff0d3e9fa375c14 to your computer and use it in GitHub Desktop.
Access CSS media queries in JavaScript
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
#media::before { | |
content: 'desktop'; | |
} | |
@media (max-width: 500px) { | |
#media::before { | |
content: 'mobile'; | |
} | |
} |
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
var cssClass = window.getComputedStyle( | |
document.querySelector('#media'), ':before' | |
).getPropertyValue('content'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment