Media Queries in JS
An interesting way to let CSS talk to JS directly. Found in this comment
It uses getComputedStyle which has it's limitations, but could be substituted with jQuery's .css() as described here
CSS
body:after {
content: 'fluid';
display: none;
}
@media only screen and (min-width: 64em) {
body:after { content: 'fixed'; }
}
JS
var size = window.getComputedStyle(document.body,':after').getPropertyValue('content')
Written by Nate Steiner
Related protips
1 Response
Nice :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#