I'm trying to implement a star rating on VisualForce, where a user hovers over a star and the star will highlight. I'm looking at the example here: CSS Star Rater .
The things I'm having trouble with is how can I get this into VF:
<span class="star-rating">
<input type="radio" name="rating" value="1"><i></i>
<input type="radio" name="rating" value="2"><i></i>
<input type="radio" name="rating" value="3"><i></i>
<input type="radio" name="rating" value="4"><i></i>
<input type="radio" name="rating" value="5"><i></i>
</span>
and highlighting the star.
Here is the CSS file that I have:
.star-rating{
font-size:0;
white-space:nowrap;
display:inline-block;
width:250px;
height:50px;
overflow:hidden;
position:relative;
background:
url('data:image/svg+xml;utf-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve"><polygon fill="#DDDDDD" points="10,0 13.09,6.583 20,7.639 15,12.764 16.18,20 10,16.583 3.82,20 5,12.764 0,7.639 6.91,6.583 "/></svg>');
background-size: contain;
}
.star-rating input{
-moz-appearance:none;
-webkit-appearance:none;
opacity: 0;
display:inline-block;
width: 20%;
height: 100%;
margin:0;
padding:0;
z-index: 2;
position: relative;
&:hover + i,
&:checked + i{
opacity:1;
}
}
.star-rating i{
opacity: 0;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 20%;
z-index: 1;
background:
url('data:image/svg+xml;utf-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve"><polygon fill="#FFDF88" points="10,0 13.09,6.583 20,7.639 15,12.764 16.18,20 10,16.583 3.82,20 5,12.764 0,7.639 6.91,6.583 "/></svg>');
background-size: contain;
}
.star-rating i ~ i{
width: 40%;
}
.star-rating i ~ i ~ i{
width: 60%;
}
.star-rating i ~ i ~ i ~ i{
width: 80%;
}
.star-rating i ~ i ~ i ~ i ~ i{
width: 100%;
}
So far, I have this VisualForce code:
<apex:page docType="html-5.0" >
<apex:stylesheet value="{!URLFOR($Resource.FeedbackStarsStyling)}"/>
<apex:outputPanel styleClass="star-rating">
<apex:form >
<apex:selectRadio layout="lineDirection">
<apex:selectOption itemValue="1"></apex:selectOption>
<i></i>
<apex:selectOption itemValue="2"></apex:selectOption>
<i></i>
<apex:selectOption itemValue="3"></apex:selectOption>
<i></i>
<apex:selectOption itemValue="4"></apex:selectOption>
<i></i>
<apex:selectOption itemValue="5"></apex:selectOption>
<i></i>
</apex:selectRadio>
</apex:form>
</apex:outputPanel>
What are the changes can I make? Or do I need to approach this entirely differently because VisualForce can't do this stuff?
Thanks!