Call the placeholder on the class or element you wish to add a background image to, like this:
@extend: %icon-NameOfImage
;
I have written this, since I was in dire need of lean sprite css. The standard output does not cut it.
Not only did not want the classes, I also did needed the files to be retina ready.
This is just a gist, so I leave out the part in which the media query negotiates the correct sprite (I hope to add it later).
The CSS is still in typical SASS fashion scattered across the CSS file:
- declaration of all elements / classed using the bg-img
- the output of %extend
- all the other css written for each class
This is still suboptimal for performance, the the smallest output I have been able to find.
It would be better to use a "smart" layout, but sprite-position
does not yield the correct positions in this case.
Any help for improvement is welcome!