Skip to content

Instantly share code, notes, and snippets.

@ntlk
Created May 22, 2014 13:46
Show Gist options
  • Save ntlk/31e89e5c3ae8ac60a405 to your computer and use it in GitHub Desktop.
Save ntlk/31e89e5c3ae8ac60a405 to your computer and use it in GitHub Desktop.
image-2x sass mixin
@mixin image-2x($image, $width: 'auto', $height: 'auto') {
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
background-image: url($image);
@if $width == 'auto' {
background-size: contain;
} @else {
background-size: $width $height;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment