快看!25款纯CSS的星级评定效果实例欣赏,非常漂亮。

html-css031

快看!25款纯CSS的星级评定效果实例欣赏,非常漂亮。,第1张

 

link: https://codepen.io/knyttneve/pen/EBNqPN

 

link: https://codepen.io/GeoffreyCrofte/pen/jEkBL

 

PS:点击黑屏,是因为点击的时候打开了新页面......,所以大家不要惊慌哈。

link: https://codepen.io/maxxscholten/pen/zxegjL

 

link: https://codepen.io/lsirivong/pen/ekBxI

 

PS:这个星级是静态的,没有动效。

link: https://codepen.io/jsdev/pen/ojycf

 

link: https://codepen.io/andreacrawford/pen/NvqJXW

 

link: https://codepen.io/meowwwls/pen/BzaWZg

 

link: https://codepen.io/elmahdim/pen/bZmwPK

 

link: https://codepen.io/mburnette/pen/eNNZbm

 

link: https://codepen.io/s_crystal/pen/pJpMZX

 

link: https://codepen.io/bennettfeely/pen/EKrENG

 

link: https://codepen.io/brigi_cs/pen/bYjGEK

 

link: https://codepen.io/airen/pen/XoJKVr

 

link: https://codepen.io/tadaima/pen/rjvYab

 

link: https://codepen.io/ryanparag/pen/prKVGZ

 

PS:这个也是静态的。。。

link: https://codepen.io/Bluetidepro/pen/GkpEa

 

link: https://codepen.io/roxy225/pen/zvKByN

 

link: https://codepen.io/khone-vongsouthi/pen/gfzoK

 

link: https://codepen.io/fusco/pen/MwawEL

 

link: https://codepen.io/kanduvisla/pen/NqdbZP

 

link: https://codepen.io/orchard/pen/Jnwvb

 

link: https://codepen.io/jexordexan/pen/yyYEJa

 

link: https://codepen.io/adrianlambertz/pen/hqpyK

 

link: https://codepen.io/damianmuti/pen/KmEMdR

 

link: https://codepen.io/blixt/pen/QyNXEp

下面是js 的评分实现,每次评分都是整数,4.2只是个平均值

用这个就可以了

SELECT avg(star) as stars FROM content where id =100

只有一个数值,就是你要的平均分,也就是4.2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>星级评分系统</title>

<style>

body,div,ul,li,p{margin:0padding:0}

body{color:#666font:12px/1.5 Arial}

ul{list-style-type:none}

#star{position:relativewidth:600pxmargin:10px auto}

#star ul,#star span{float:leftdisplay:inlineheight:19pxline-height:19px}

#star ul{margin:0 10px}

#star li{float:leftwidth:24pxcursor:pointertext-indent:-9999pxbackground:url(/jscss/demoimg/201206/star.png) no-repeat}

#star strong{color:#f60padding-left:10px}

#star li.on{background-position:0 -28px}

#star p{position:absolutetop:20pxwidth:159pxheight:60pxdisplay:nonebackground:url(/jscss/demoimg/201206/icon.gif) no-repeatpadding:7px 10px 0}

#star p em{color:#f60display:blockfont-style:normal}

</style>

<script type="text/javascript">

window.onload = function ()

{

var oStar = document.getElementById("star")

var aLi = oStar.getElementsByTagName("li")

var oUl = oStar.getElementsByTagName("ul")[0]

var oSpan = oStar.getElementsByTagName("span")[1]

var oP = oStar.getElementsByTagName("p")[0]

var i = iScore = iStar = 0

var aMsg = [

"很不满意|差得太离谱,与卖家描述的严重不符,非常不满",

"不满意|部分有破损,与卖家描述的不符,不满意",

"一般|质量一般,没有卖家描述的那么好",

"满意|质量不错,与卖家描述的基本一致,还是挺满意的",

"非常满意|质量非常好,与卖家描述的完全一致,非常满意"

]

for (i = 1i <= aLi.lengthi++)

{

aLi[i - 1].index = i

//鼠标移过显示分数

aLi[i - 1].onmouseover = function ()

{

fnPoint(this.index)

//浮动层显示

oP.style.display = "block"

//计算浮动层位置

oP.style.left = oUl.offsetLeft + this.index * this.offsetWidth - 104 + "px"

//匹配浮动层文字内容

oP.innerHTML = "<em><b>" + this.index + "</b>分 " + aMsg[this.index - 1].match(/(.+)\|/)[1] + "</em>" + aMsg[this.index - 1].match(/\|(.+)/)[1]

}

//鼠标离开后恢复上次评分

aLi[i - 1].onmouseout = function ()

{

fnPoint()

//关闭浮动层

oP.style.display = "none"

}

//点击后进行评分处理

aLi[i - 1].onclick = function ()

{

iStar = this.index

oP.style.display = "none"

oSpan.innerHTML = "<strong>" + (this.index) + " 分</strong>(" + aMsg[this.index - 1].match(/\|(.+)/)[1] + ")"

}

}

//评分处理

function fnPoint(iArg)

{

//分数赋值

iScore = iArg || iStar

for (i = 0i <aLi.lengthi++) aLi[i].className = i <iScore ? "on" : ""

}

}

</script>

</head>

<body>

<div id="star">

<span>点击星星就能打分</span>

<ul>

<li><a href="javascript:">1</a></li>

<li><a href="javascript:">2</a></li>

<li><a href="javascript:">3</a></li>

<li><a href="javascript:">4</a></li>

<li><a href="javascript:">5</a></li>

</ul>

<span></span>

<p></p>

</div>

</body>

</html>