星星评分-简版
纯属自己的想法
最近在做一个项目用到星星评分,然后就各种找插件,还是不能满足我的要求,然后就自己写了一个,笨方法,可能不是很好,记录一下。
新的改变
/评分/
.box
{
width:100px;
height:20px;
/*background:#f4cea3;*/
background: url(../images/icon/xingxing1.png) top left repeat-x;
font-size: 7px;
position:relative
}
.rate
{
/*width:50px;*/
height:100%;
/*background:red;*/
background: url(../images/icon/xingxing2.png) top left repeat-x;
position:absolute;
}
.rate_text
{
width:100%;
height:100%;
top:12.5%;
position:absolute;
text-align:center;
vertical-align:middle;
color: red;
font-size: 15px;
font-family: monospace;
}
- js 动态添加
str +=“<div class="box">“;
str +='<div id="score_rate" class="rate">';
str +='</div>';
str +='<div class="rate_text" id="score_text"></div>';
str +=''+producList[i].score+'</div>';
3.根据后台数据显示星星个数
//评分
if (scoreList ==4 ) {
$(".rate").width('75%');
}