Skip to content

Instantly share code, notes, and snippets.

@brianmcallister
Created July 19, 2012 22:28
Show Gist options
  • Save brianmcallister/3147307 to your computer and use it in GitHub Desktop.
Save brianmcallister/3147307 to your computer and use it in GitHub Desktop.
Retina sprite background image mixin.
/*
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;
}
# 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
@brianmcallister
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment