纯CSS实现星级评分组件

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)

相关推荐
云水一下7 小时前
TypeScript 从零基础到精通(五):高级类型与泛型
前端·javascript·typescript
counterxing7 小时前
vibe coding 之后,我更不想打字了
前端·agent·ai编程
copyer_xyf7 小时前
Python 模块与包的导入导出
前端·后端·python
研☆香7 小时前
es6新特性功能介绍(四)
前端·ecmascript·es6
微扬嘴角7 小时前
React篇1--JSX语法规则、组件、组件实例的3大特性
前端·react.js·前端框架
copyer_xyf8 小时前
Python venv 虚拟环境
前端·后端·python
无聊的老谢8 小时前
Vue 3 + TypeScript 构建大型电信运维平台的前端架构设计
前端·vue.js·typescript
xiaofeichaichai8 小时前
Map / Set / WeakMap / WeakSet
前端·javascript
李可以量化8 小时前
成交量的终极量化策略:价量共振指标完整实现(下篇)
前端·数据库·人工智能
copyer_xyf9 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python