Created
April 10, 2015 14:42
-
-
Save zephster/8e5df481ad44800b1e49 to your computer and use it in GitHub Desktop.
pure css star ratings
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
<style> | |
.search-minimum-rating { | |
border : none; | |
float : left; | |
padding: 0; | |
} | |
.search-minimum-rating > input { | |
display: none; | |
} | |
.search-minimum-rating > label:before { | |
margin : 5px; | |
font-size : 1.25em; | |
display : inline-block; | |
text-shadow: 0 0 1px #000; | |
content : "\2605"; | |
} | |
.search-minimum-rating > label { | |
color : #c0c0c0; | |
float : right; | |
cursor: pointer; | |
} | |
.search-minimum-rating > input:checked ~ label, /* show gold star when clicked */ | |
.search-minimum-rating:not(:checked) > label:hover, /* hover current star */ | |
.search-minimum-rating:not(:checked) > label:hover ~ label { /* hover previous stars in list */ | |
color: #FFD700; | |
} | |
.search-minimum-rating > input:checked + label:hover, /* hover previous stars when changing rating */ | |
.search-minimum-rating > input:checked ~ label:hover, /* hover current star when changing rating */ | |
.search-minimum-rating > label:hover ~ input:checked ~ label, /* lighten current selection */ | |
.search-minimum-rating > input:checked ~ label:hover ~ label { | |
color: #FFED85; | |
} | |
</style> | |
<fieldset class="search-minimum-rating"> | |
<input type="radio" id="star5" name="min_rating" value="5"><label for="star5"></label> | |
<input type="radio" id="star4" name="min_rating" value="4"><label for="star4"></label> | |
<input type="radio" id="star3" name="min_rating" value="3" checked="checked"><label for="star3"></label> | |
<input type="radio" id="star2" name="min_rating" value="2"><label for="star2"></label> | |
<input type="radio" id="star1" name="min_rating" value="1"><label for="star1"></label> | |
</fieldset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment