Created
July 19, 2012 22:28
-
-
Save brianmcallister/3147307 to your computer and use it in GitHub Desktop.
Retina sprite background image mixin.
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
/* | |
This pretty much doesn't work at all right now. | |
*/ | |
@mixin retina-general-sprite($name, $set-dimensions: true) { | |
$sprite-width: image-width('general.png'); | |
$sprite-height: image-height('general.png'); | |
$sprite-file-url: sprite-file($general-sprite, $name); | |
$sprite-file-width: image-width($sprite-file-url) / 2; | |
$sprite-file-height: image-height($sprite-file-url) / 2; | |
@if $set-dimensions { | |
display: block; | |
width: $sprite-file-width; | |
height: $sprite-file-height; | |
} | |
background: no-repeat image-url('general.png'); | |
background-position: sprite-position($general-sprite, $name); | |
// background-size: 100%; | |
background-size: $sprite-file-width $sprite-file-height; | |
} |
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
# Add this to the config.rb to remove the random string on the back of the sprite filename. | |
on_sprite_saved do |filename| | |
if File.exists?(filename) | |
FileUtils.mv filename, filename.gsub(%r{-s[a-z0-9]{10}\.png$}, '.png') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I realize this wasn't as clear as it could be, but by 'standalone images', I mean this could work for sprites that are not generated by Compass as well.