Created
April 23, 2014 20:28
-
-
Save ryanlewis/11231156 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// 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; | |
} |
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
#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