Skip to content

Instantly share code, notes, and snippets.

@nkcmr
Created December 11, 2012 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkcmr/4259098 to your computer and use it in GitHub Desktop.
Save nkcmr/4259098 to your computer and use it in GitHub Desktop.
css media query actions in javascript
var queries = [{
'match_this': 'only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5)',
'action': function () {
$('.post .entry-content img').each(function (index, element) {
$(this).attr('width', '100%');
$(this).removeAttr('height');
});
}
}, {
'match_this': 'only screen and (min-width : 321px)',
'action': function () {
$('.post .entry-content img').each(function (index, element) {
$(this).attr('width', '100%');
$(this).removeAttr('height');
});
}
}, {
'match_this': 'only screen',
'action': function () {
console.warn('NO MQ MATCHES: RESORT TO DEFAULT');
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment