Skip to content

Instantly share code, notes, and snippets.

@shaneriley
Created August 15, 2012 14:13
Show Gist options
  • Save shaneriley/3360504 to your computer and use it in GitHub Desktop.
Save shaneriley/3360504 to your computer and use it in GitHub Desktop.
Rating stars
.rating
.current.three
- %w(one two three four five).each do |rating|
= link_to rating, "#", class: rating
.rating
position: relative
width: 100px
height: 14px
background: transparent url("icon_rating.png") 0 0 repeat-x
$ratings: one, two, three, four, five
&:hover
.current
display: none
.current
position: absolute
left: 0
top: 0
bottom: 0
z-index: 1
background: transparent url("icon_rating.png") 0 100% repeat-x
@for $i from 1 through length($ratings)
&.#{nth($ratings, $i)}
width: $i * 20px
a
position: absolute
left: 0
top: 0
bottom: 0
z-index: 1
text-indent: -8685px
overflow: hidden
@for $i from 1 through length($ratings)
&.#{nth($ratings, $i)}
width: $i * 20px
z-index: length($ratings) - ($i - 1)
&:hover
background: transparent url("icon_rating.png") 0 100% repeat-x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment