Skip to content

Instantly share code, notes, and snippets.

@johnantoni
Last active August 29, 2015 13:56
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 johnantoni/9118470 to your computer and use it in GitHub Desktop.
Save johnantoni/9118470 to your computer and use it in GitHub Desktop.
retina-ready sass mixin
/*
* Retina helper mixins for Compass
*/
@import "compass/css3/background-size";
@mixin background-image-retina($file, $type) {
$image: ($file + '.' + $type);
background-image: image-url($image);
height: image-height($image);
width: image-width($image);
@media only screen and (-webkit-min-device-pixel-ratio: 2)
{
$image2x: ($file + '@2x.' + $type);
background-image: image-url($image2x);
@include background-size(image-width($image) auto);
}
}
@mixin image-replacement($file, $type) {
@include background-image-retina($file, $type);
background-position: 0 0;
background-repeat: no-repeat;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
display: block;
}
@johnantoni
Copy link
Author

add image replacement mixin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment