Skip to content

Instantly share code, notes, and snippets.

@ryanlewis
Created April 23, 2014 20:28
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 ryanlewis/11231156 to your computer and use it in GitHub Desktop.
Save ryanlewis/11231156 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.5)
// Compass (v1.0.0.alpha.18)
// ----
@mixin image2x-retina($file, $type, $width, $height, $mod: '@2x') {
$fileName: $file + '.' + $type;
$retina: $file + $mod + '.' + $type;
background-image: url($fileName);
@media (-webkit-min-device-pixel-ratio: 1.5), (-moz-min-device-pixel-ratio: 1.5) {
& {
background-image: url($retina);
background-size: $width $height;
}
}
}
// Example
#foo {
@include image2x-retina('foobar', 'png', 10px, 20px);
background: repeat;
}
#foo {
background-image: url("foobar.png");
background: repeat;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (-moz-min-device-pixel-ratio: 1.5) {
#foo {
background-image: url("foobar@2x.png");
background-size: 10px 20px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment