Last active
August 29, 2015 13:56
-
-
Save johnantoni/9118470 to your computer and use it in GitHub Desktop.
retina-ready sass mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add image replacement mixin