Skip to content

Instantly share code, notes, and snippets.

@jeffjewiss
Forked from twe4ked/input.scss
Created March 14, 2012 16:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffjewiss/2037683 to your computer and use it in GitHub Desktop.
Save jeffjewiss/2037683 to your computer and use it in GitHub Desktop.
FREE! Sass (SCSS) mixin for including retina images (useful when developing for iOS).
@mixin background-image-retina($file, $type, $width, $height) {
background-image: url($file + '.' + $type);
@media (-webkit-min-device-pixel-ratio: 2) {
& {
background-image: url($file + '@2x.' + $type);
-webkit-background-size: $width $height;
}
}
}
// Example
#foo {
@include background-image-retina('foobar', 'png', 10px, 20px);
background: repeat;
}
#foo {
background-image: url("foobar.png");
background: repeat; }
@media (-webkit-min-device-pixel-ratio: 2) {
#foo {
background-image: url("foobar@2x.png");
-webkit-background-size: 10px 20px; } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment