I use this code to display stars:
You expected thing is possible with only css. Because css rule is applied for next sibling not for previous. You should also use JQuery.
But you can do it using following trick using css:
.rating input { display: none; }
.rating label:before {
margin: 5px;
font-size: 1.25em;
font-family: FontAwesome;
display: inline-block;
content: "\f005";
}
li {list-style:none;
direction:rtl;
text-align: left;}
.rating label {
color: #ffffd;
}
/***** CSS to Highlight Stars on Hover *****/
.rating input:checked ~ label, /* show gold star when clicked */
.rating:not(:checked) label:hover, /* hover current star */
.rating:not(:checked) label:hover ~ label { color: #FFD700; } /* hover previous stars in list */
.rating input:checked + label:hover, /* hover current star when changing rating */
.rating input:checked ~ label:hover,
.rating label:hover ~ input:checked ~ label, /* lighten current selection */
.rating input:checked ~ label:hover ~ label { color: #FFED85; }