I have seen many star-level examples, but I can only select integers.
I made an example by myself, which can be accurate to the percentage.
Ideas:
1. display different star image styles through three layers. The first layer is the default display of images, the second layer is the selected form, and the third layer is the event control layer.
2. The onmousemove event is used to display the star level on the top layer.
For details, see the code. It is not made into a class or anything. It's just a thought.
Code
<Html>
<Head>
<Script language = "javascript">
Function stopBubble (e ){
If (e & e. stopPropagation)
E. stopPropagation ();
Else
Window. event. cancelBubble = true;
}
Function getElementX (e ){
Return (e & e. layerX) | window. event. offsetX;
}
Window. onload = function (){
Window. test = Document. getelementbyid ("test ");
VaR starb = Document. getelementbyid ("starbak ");
Starb. style. width = "64px ";
Starb. style. Height = "32px ";
VaR star = Document. getelementbyid ("star ");
Star. style. Top = starb. style. Top;
Star. style. Left = starb. style. Top;
VaR Staro = Document. getelementbyid ("starover ");
Staro. style. Top = starb. style. Top;
Staro. style. Left = starb. style. Top;
Staro. style. width = "64px ";
Staro. style. Height = "32px ";
Staro. onmousemove = function (e ){
VaR x = getelementx (E );
// Var sb = Document. getelementbyid ("starbak ");
// Sb. style. width = x + "PX ";
VaR sr = Document. getelementbyid ("star ");
Sr. style. width = x + "PX ";
Window. Test. innerhtml = X;
StopBubble (e );
}
Staro. onclick = function (e)
{
Alert (window. test. innerHTML );
}
}
</Script>
</Head>
<Body>
Fasdfasd </br>
<Div id = "test">
</Div>
<Div id = "starcontrol">
<Div id = "starbak" style = "position: absolute; background-image: url(award_star_silver_3.png); z-index: 0"> </div>
<Div id = "star" style = "position: absolute; z-index: 11; background-image: url(knewstuff.png);"> </div>
<Div id = "starover" style = "position: absolute; z-index: 26; background-image: url(back.gif); CURSOR: hand;"> </div>
</Div>
<Div id = "starcontrol1">
<Div id = "startb1" style = "background-image: url(award_star_silver_3.png); z-index: 0"> </div>
<Div id = "star11" style = "position: relative; top:-22px; left: 0px; background-image: url(knewstuff.png); z-index: 0 "> </div>
</Div>
</Body>
</Html>
Download:
Precise star instance