Skip to content

Instantly share code, notes, and snippets.

@hannigand
Last active August 29, 2015 14:05
Show Gist options
  • Save hannigand/03b3c4e483c3d942d0b1 to your computer and use it in GitHub Desktop.
Save hannigand/03b3c4e483c3d942d0b1 to your computer and use it in GitHub Desktop.
Playing with Spritesheets with Sass
$icon-width: 24px;
$icon-height: 24px;
$icon-tile-x: 10;
$icons: 'http://danhannigan.co.uk/social_spritesheet.png';
%social-icon {
width: $icon-width;
height: $icon-height;
background-image: url($icons);
display: block;
}
$social-icons: (
'android',
'linkedin',
'facebook',
'twitter',
'unknown_one',
'pinterest',
'youtube-play',
'email',
'unknown_two',
'youtube',
'quora',
'unknown_three',
'apple',
'rss',
'tumblr'
);
@each $icon in $social-icons {
$i: index($social-icons, $icon) - 1;
.#{$icon} {
@extend %social-icon;
background-position-x: -($i * 24px);
@if $i < $icon-tile-x {
background-position-y: 0px;
} @else {
background-position-y: $icon-width;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment