js
//html
<input type="range" name="star" min="0" max="5" step="0.5">
//css
input[type="range"]{
-webkit-appearance: none;
width: 1.9rem;
margin: 0;
outline: 0;
}
input[type="range" i]::-webkit-slider-runnable-track {
background: #facc01;
height: 0.38rem;
-webkit-mask: url("../img/star.png");
-webkit-mask-size: 0.38rem;
-webkit-mask-repeat: repeat-x;
}
input[type="range" i]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 0;
height: 100%;
box-shadow: 999px 0px 0px 999px #f2f2f8;
}
/* 火狐 */
input[type=range]{
-webkit-mask: url("../img/star.png");
-webkit-mask-size: 0.38rem;
-webkit-mask-repeat: repeat-x;
height: 0.38rem;
}
input[type=range]::-moz-range-track{
background: #f2f2f8; //星星颜色
height: inherit;
}
input[type=range]::-moz-range-progress {
background: #facc01; //背景颜色
height: inherit;
}
input[type=range]::-moz-range-thumb {
width: 0;
opacity: 0;
}
图片文件(star.png)