本文实例为大家分享了js实现星级评价效果展示的具体代码,供大家参考,具体内容如下
背景图片实现
图片是width:36px; height:25px;
背景是白色,中间一个空的五角星,空的边缘有一像素的边框;(不然就看不到了);
星级评价(可半星).xin{height: 25px; background: url(images/x.png); position: relative; display: inline-block;}
.xin span{display: block; height: 25px; background: #f60; position: absolute; left: 0; top: 0;z-index: -1;transition: 0.2s;}
.xin ul{position: absolute; top: 0; left: 0; height: 25px; margin: 0; padding: 0; list-style: none;}
.xin ul li{float: left; width: 18px; height: 25px;}
.fensu{display: inline-block;}
var input=document.querySelectorAll("input[type=hidden]");
input.forEach(function(_input){
var Div=document.createElement("div");
Div.className="xin";
Div.style.width=18*(_input.title || 5)*2 + "px";
_input