Created
October 5, 2012 00:32
-
-
Save estahn/3837343 to your computer and use it in GitHub Desktop.
Using Compass to generate normal and retina sprite maps at once
This file contains hidden or 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
@mixin all-retina-sprites($map, $map2x) { | |
@media (min--moz-device-pixel-ratio: 1.5), | |
(-o-min-device-pixel-ratio: 3/2), | |
(-webkit-min-device-pixel-ratio: 1.5), | |
(min-device-pixel-ratio: 1.5), | |
(min-resolution: 1.5dppx) { | |
$base-class: sprite-map-name($map); | |
.#{$base-class}-all-retina-sprites { | |
background-image: sprite-url($map2x); | |
@include background-size(ceil(image-width(sprite-path($map2x)) / 2) auto); | |
} | |
@each $sprite in sprite-names($map) { | |
.#{$base-class}-#{$sprite} { | |
@extend .#{$base-class}-all-retina-sprites; | |
$position: sprite-position($map2x, $sprite); | |
background-position: nth($position, 1) nth($position, 2) / 2; | |
} | |
} | |
} | |
} |
This file contains hidden or 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
// Sprite set: General | |
// ---------------------------------------- | |
//$general-layout: smart; | |
$general-spacing: 1px; | |
$general-sprite-dimensions: true; | |
@import "general/*.png"; | |
@include all-general-sprites; | |
$general-retina-spacing: 1px; | |
$general-retina-sprite-dimensions: true; | |
@import "general-retina/*.png"; | |
//@include all-general-retina-sprites; | |
@include all-retina-sprites($general-sprites, $general-retina-sprites); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is perfect for what I needed! Thank you.