Skip to content

Instantly share code, notes, and snippets.

@indigofeather
Created March 17, 2016 13:39
Show Gist options
  • Save indigofeather/c47652664d624415b3c7 to your computer and use it in GitHub Desktop.
Save indigofeather/c47652664d624415b3c7 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
$png: -0px -0px 68px 68px;
$jpg: -0px -68px 260px 260px;
@mixin sprite-width($sprite) {
width: nth($sprite, 3);
}
@mixin sprite-height($sprite) {
height: nth($sprite, 4);
}
@function sprite-width($sprite) {
@return nth($sprite, 3);
}
@function sprite-height($sprite) {
@return nth($sprite, 4);
}
@mixin sprite-position($sprite) {
$sprite-offset-x: nth($sprite, 1);
$sprite-offset-y: nth($sprite, 2);
background-position: $sprite-offset-x $sprite-offset-y;
}
@mixin sprite($sprite, $display: block) {
@include sprite-position($sprite);
background-repeat: no-repeat;
overflow: hidden;
display: $display;
@include sprite-width($sprite);
@include sprite-height($sprite);
}
.icon {
background-image: url("../images/sprite.png");
}
// map
$map: (
png: $png,
jpg: $jpg
);
// loop
@each $key, $val in $map {
.icon-#{$key} {
@include sprite(map-get($map, $key))
}
}
.icon {
background-image: url("../images/sprite.png");
}
.icon-png {
background-position: 0px 0px;
background-repeat: no-repeat;
overflow: hidden;
display: block;
width: 68px;
height: 68px;
}
.icon-jpg {
background-position: 0px -68px;
background-repeat: no-repeat;
overflow: hidden;
display: block;
width: 260px;
height: 260px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment