Last active
August 29, 2015 14:05
-
-
Save hannigand/03b3c4e483c3d942d0b1 to your computer and use it in GitHub Desktop.
Playing with Spritesheets with Sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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