Skip to content

Instantly share code, notes, and snippets.

@benknight
Last active August 29, 2015 14:16
Show Gist options
  • Save benknight/6ec1989d994e3e39ba1d to your computer and use it in GitHub Desktop.
Save benknight/6ec1989d994e3e39ba1d to your computer and use it in GitHub Desktop.
Media query mixin
$on-wide: 'screen and (min-width: 1600px)';
$off-wide: 'screen and (max-width: 1599px)';
$on-desktop: 'screen and (min-width: 850px)';
$off-desktop: 'screen and (max-width: 849px)';
$on-medium: 'screen and (max-width: 600px)';
$off-medium: 'screen and (min-width: 600px)';
$on-mobile: 'screen and (max-width: 480px)';
$off-mobile: 'screen and (min-width: 481px)';
$on-portrait: 'screen and (max-width: 400px)';
$on-retina: '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)';
$on-ipad: '(device-width: 768px) and (device-height: 1024px)';
@mixin media-query($queries...) {
@media #{$queries} {
@content;
}
}
// Usage:
@include media-query($on-ipad, $off-desktop) {
// do stuff...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment