Last active
August 29, 2015 13:56
-
-
Save dcalhoun/2da26ec6dd0f8ff1764f to your computer and use it in GitHub Desktop.
Custom icons loop.
This file contains hidden or 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
// Position icon background image | |
@mixin icon($index, $y: 0, $width: 80px) { | |
background-position: #{($index * -$width)} $y; | |
} |
This file contains hidden or 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: users, megaphone, gavel, warning, chat, faq, pen-paper, document, | |
pdf, checklist, scale, charts, calendar, search, mail, scroll, | |
scroll-44, info, url; | |
.bopr-icon { | |
background: image-url('bopr-icons.png') no-repeat 0 0; | |
display: inline-block; | |
height: 80px; | |
width: 80px; | |
@include hidpi(2) { | |
background-image: image-url('bopr-icons_2x.png'); | |
background-size: auto 160px; | |
} | |
// Loop through icon names to build backgrounds | |
@for $i from 1 through length($icon) { | |
$index: $i - 1; // Pseudo zero-based index | |
$class: nth($icon, $i); // Icon name | |
&.#{$class} { | |
@include icon($index); // Output background-position | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment