Skip to content

Instantly share code, notes, and snippets.

@jaredkc
Created December 10, 2014 01:36
Show Gist options
  • Select an option

  • Save jaredkc/3d701e7c66fc51269adf to your computer and use it in GitHub Desktop.

Select an option

Save jaredkc/3d701e7c66fc51269adf to your computer and use it in GitHub Desktop.
Sass Retina Sprite Mixin
// --------------------------------------------------
// Sprite along with retina version.
// --------------------------------------------------
@mixin sprite($xpos, $ypos, $width: 600px, $height: 600px) {
background-image: url(../img/sprite.png);
background-position: $xpos $ypos;
background-repeat: no-repeat;
// Solution for retina graphics.
// Variation of: http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
@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(../img/[email protected]);
-webkit-background-size: $width $height;
background-size: $width $height;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment