Skip to content

Instantly share code, notes, and snippets.

@jkochis
Created December 2, 2014 13:55
Show Gist options
  • Save jkochis/5e4f50cf6b39a5fa9a70 to your computer and use it in GitHub Desktop.
Save jkochis/5e4f50cf6b39a5fa9a70 to your computer and use it in GitHub Desktop.
Percentage based star ratings
// change this to adjust the rating display
var bvTireRating = 2.5;
// multiply by 20 to get percentage
var starRating = bvTireRating*20;
// set the width of the stars
$('.star-ratings-top').width(starRating+'%');
.star-ratings {
unicode-bidi: bidi-override;
color: #c5c5c5;
font-size: 50px;
height: 50px;
width: 250px;
margin: 1em auto;
position: relative;
padding: 0;
.star-ratings-top {
color: gold;
padding: 0;
position: absolute;
z-index: 1;
display:block;
left: 0px;
overflow: hidden;
}
.star-ratings-bottom { z-index: 0; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment