ruk·si

🎨 CSS
Media Query State to JavaScript

Updated at 2012-12-20 11:30

A way to pass media query state to JavaScript.

@media (min-width: 400px) {
    body:after {
        content: 'widescreen';
        display: none;
    }
}
var size = window
    .getComputedStyle(document.body, ':after')
    .getPropertyValue('content');

if (size === 'widescreen') {
    // ...
}