Star Ratings - CSS - FontAwesome
Star Ratings using pure CSS, powered by FontAwesome.
HTML
<div class="rating-field">
<input type="radio" id="field-score-5" name="score" value="5" />
<label title="5 Stars" for="field-score-5">5 Stars</label>
<input type="radio" id="field-score-4" name="score" value="4" />
<label title="4 Stars" for="field-score-4">4 Stars</label>
<input type="radio" id="field-score-3" name="score" value="3" />
<label title="3 Stars" for="field-score-3">3 Stars</label>
<input type="radio" id="field-score-2" name="score" value="2" />
<label title="2 Stars" for="field-score-2">2 Stars</label>
<input type="radio" id="field-score-1" name="score" value="1" />
<label title="1 Star" for="field-score-1">1 Star</label>
</div>
CSS
/* ===================== */
/* == FontAwesome == */
/* ===================== */
@font-face {
font-family:'FontAwesome';
src:url(https://netdna.bootstrapcdn.com/font-awesome/5.0/font//fontawesome-webfont.eot?#iefix) format('eot'),
url(https://netdna.bootstrapcdn.com/font-awesome/5.0/font//fontawesome-webfont.woff) format('woff'),
url(https://netdna.bootstrapcdn.com/font-awesome/5.0/font//fontawesome-webfont.ttf) format('truetype'),
url(https://netdna.bootstrapcdn.com/font-awesome/5.0/font//fontawesome-webfont.svg#FontAwesome) format('svg');
font-weight: normal;
font-style: normal;
}
/* ===================== */
/* == CSS Rate-It Bar == */
/* ===================== */
div.rating-field {
text-align:center;
font-size:0;
direction:rtl;
background-color:transparent;
height:20px;
width:102px;
border-style:solid;
border-width:1px;
border-color:#777777;
border-radius:5px;
box-sizing;border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
user-select:none;
-moz-user-select:none;
-webkit-user-select:none;
}
div.rating-field > input[type="radio"] {
position:absolute;
top:-32px;
clip:rect(0,0,0,0);
}
div.rating-field > label {
font-size:14px;
line-height:22px;
text-align:center;
display:inline-block;
position:relative;
width:20px;
height:20px;
overflow:hidden;
text-indent:100%;
}
div.rating-field > label:before {
font-family:'FontAwesome';
content:'\f100';
position:absolute;
top: 0px;
left: 0px;
width:100%;
height:100%;
line-height:20px;
text-indent:0;
color:#777777;
padding-top:0px;
box-sizing;border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
div.rating-field > input[type="radio"]:checked ~ label:before {
font-family:'FontAwesome';
content:'\f005';
color:#e3cf7a;
}
div.rating-field...