Created
October 14, 2011 13:53
-
-
Save hshoff/1287174 to your computer and use it in GitHub Desktop.
Airbnb - Star Rating SASS
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
// stars.scss | |
// compiles to stars.css | |
$starWidth: 44px; | |
$starOffset: 0 -43px; | |
$numStars: 5; | |
$steps: 2; | |
$total: $numStars * $steps; | |
@mixin filled($n: 0) { | |
width: ($starWidth / $steps) * $n; | |
} | |
.stars { | |
background: url(/images/sprite.png) repeat-x top left; | |
height: 43px; | |
&.empty { | |
background-position: $starOffset; | |
width: $numStars * $starWidth; | |
} | |
@for $i from 0 through ($total) { | |
&.filled_#{$i} { @include filled($i) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment