Skip to content

Instantly share code, notes, and snippets.

@niallobrien niallobrien/app.js
Created Aug 21, 2014

What would you like to do?
Execute JS based on the current screen-size (Foundation's media queries)
var mediaStateContainer = document.querySelector('.mq'),
mediaState = window.getComputedStyle(mediaStateContainer, ':before').getPropertyValue('content');
if (mediaState === 'small' ) {
// JS to run when we're on mobile.
.mq {
&:before {
content: 'small';
position: absolute;
display: none;
width: 0;
height: 0;
@media #{$medium-up} {
.mq:before {
content: 'medium';
@media #{$large-up} {
.mq:before {
content: 'large';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.