Last active
May 7, 2016 16:01
-
-
Save xto3na/aeedf3884a0c81f06394e6022a5206cc to your computer and use it in GitHub Desktop.
Star Rating on CSS
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
<!-- HTML --> | |
<div class="star-box"> | |
<input id="rating-5" type="radio" name="rating" value="5" /> | |
<label class="star-lbl" for="rating-5"></label> | |
<input id="rating-4" type="radio" name="rating" value="4" /> | |
<label class="star-lbl" for="rating-4"></label> | |
<input id="rating-3" type="radio" name="rating" value="3" /> | |
<label class="star-lbl" for="rating-3"></label> | |
<input id="rating-2" type="radio" name="rating" value="2" /> | |
<label class="star-lbl" for="rating-2"></label> | |
<input id="rating-1" type="radio" name="rating" value="1" /> | |
<label class="star-lbl" for="rating-1"></label> | |
</div> | |
/* SCSS */ | |
.star-box { | |
display: inline-block; | |
padding-left: 15px; | |
.star-lbl { | |
float: right; | |
display: block; | |
width: 48px; | |
height: 45px; | |
margin-right: 10px; | |
cursor: pointer; | |
background:transparent url('../image/icons/favorite_green.png') center no-repeat; | |
} | |
input[type="radio"] { | |
position: absolute; | |
opacity: 0 !important; | |
&:checked ~ label, | |
&:hover ~ label { | |
background:transparent url('../image/icons/favorite_green_active.png') center no-repeat; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment