I am building a little star CSS rating via some radio buttons and have it working ok. I am having an issue being able to fill in the stars before the radio selected, so if star 3 is selected, star 1 and 2 would also be filled in. Here is what I have so far:
#review-form input,
#review-form textarea {
background: none repeat scroll 0 0 #333333;
border: 0 none;
color: #fff;
margin: 0;
max-width: 100%;
padding: 7px 4px;
}
#review-form .radio {
display: inline-block;
}
#review-form input[type=radio] {
display: none;
}
#review-form input[type=radio] + label {
display: block;
}
#review-form input[type='radio'] + label:before {
display: inline-block;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
padding-right: 8px;
width: 23px;
}
#review-form input[type=radio] + label:before {
content: "\f006"; /* Radio Unchecked */
}
#review-form input[type=radio]:checked + label:before {
content: "\f005"; /* Radio Checked */
}
<link href="//netdna.bootstrapcdn.com/font-awesome/3.0/css/font-awesome.css" rel="stylesheet" />
<div class="form-group" id="review-form">
<label for="rating">RATING</label>
<span class="star-rating star-5">
<div class="radio">
<input type="radio" id="option1" name="star-radios" value="1">
<label for="option1"></label>
</div>
<div class="radio">
<input type="radio" id="option2" name="star-radios" value="2">
<label for="option2"></label>
</div>
<div class="radio">
<input type="radio" id="option3" name="star-radios" value="3">
<label for="option3"></label>
</div>
<div class="radio">
<input type="radio" id="option4" name="star-radios" value="4">
<label for="option4"></label>
</div>
<div class="radio">
<input type="radio" id="option5" name="star-radios" value="5">
<label for="option5"></label>
</div>
</span>
</div>
I am wondering if there is a CSS selector (or something) available where I can make the change the stars previous to the select radio button. Trying to avoid using JS if I can.