-
-
Save haribote/4072251 to your computer and use it in GitHub Desktop.
Using Compass to generate retina sprite maps at once
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
@mixin all-retina-sprites($map, $dimensions: false){ | |
$base-class: sprite-map-name($map); | |
.#{$base-class}-retina-sprite{ | |
background: sprite-url($map) no-repeat; | |
@include background-size(ceil(image-width(sprite-path($map)) / 2) auto); | |
} | |
@each $sprite in sprite-names($map){ | |
.#{$base-class}-#{$sprite}{ | |
@extend .#{$base-class}-retina-sprite; | |
@if $dimensions{ | |
width: ceil(image-width(sprite-file($map, $sprite)) / 2); | |
height: ceil(image-height(sprite-file($map, $sprite)) / 2); | |
} | |
$pos: sprite-position($map, $sprite); | |
background-position: ceil(nth($pos, 1) / 2) ceil(nth($pos, 2) / 2); | |
} | |
} | |
} |
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
// Sprite set: General | |
// ---------------------------------------- | |
//$general-layout: smart; | |
$general-retina-spacing: 1px; | |
@import "general-retina/*.png"; | |
//@include all-general-retina-sprites; | |
@include all-retina-sprites($general-retina-sprites, $dimensions: true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment