Some utils for responsive compass sprite.
As we all know, Compass is a great css framework. It can help us to automaticly merge the pngs to a sprite.
However, when the css3 background-size
is used in the css stylesheet, we need more to do to adjust the sprite with the html label.
background-size
is to stretch the background image to fit the designated html label. When we merge to the sprite, we have to stretch the large sprite not the
original small png picture. So the background-size
must be dynamicly calculated.
cal_background_size
$em
, the width of the desinated html label to contain the background image.$map
, the reference to the merged sprites.$name
, the name of the original png picture.
@import "compass/utilities/sprites";
// our scss utils
@import "utils";
$icons: sprite-map("path-to-your-images/*.png");
.test {
$test-width: 10rem; // can be px, em or other unit
@include cal_background_size($test-width, $icons, name-of-your-png-file);
}
render_sprites_css
$map
, the reference to the merged sprite.$base-class
, the base class name.$dimensions
, should we write the original width and height to the generated css styles. Default isfalse
.$prefix
, the prefix of the generated css class. Default isicon
.$offset-x
, the default offset-x of the background-position of the css class. Default is0
.$offset-y
, the default offset-y of the background-position of the css class. Default is0
.$use-percentage
, should the background-position displayed by percentage? Default istrue
.$icon-repeat
, should we use the background-repeat: repeat?. Default isno-repeat
.
@import "compass/utilities/sprites";
// our scss utils
@import "utils";
$icons: sprite-map("path-to-your-images/*.png");
@include render_sprites_css($icons, 'sprite');