html--星星打分

html

html 复制代码
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Star Rating</title>

<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/ionicons/4.5.6/css/ionicons.min.css'>

<link rel="stylesheet" href="css/style.css">

</head>
<body>

<div class="rating">
  <input type="radio" name="rating" id="5" value="5" />
  <label for="5"><i class="icon ion-md-star-outline"></i></label>
  <input type="radio" name="rating" id="4" value="4" />
  <label for="4"><i class="icon ion-md-star-outline"></i></label>
  <input type="radio" name="rating" id="3" value="3" />
  <label for="3"><i class="icon ion-md-star-outline"></i></label>
  <input type="radio" name="rating" id="2" value="2" />
  <label for="2"><i class="icon ion-md-star-outline"></i></label>
  <input type="radio" name="rating" id="1" value="1" />
  <label for="1"><i class="icon ion-md-star-outline"></i></label>
</div>

  
</body>
</html>

css

css 复制代码
body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #222;
}

.rating {
  display: flex;
  flex-direction: row-reverse;
  font-family: "Ionicons";
}
.rating input {
  opacity: 0;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}
.rating input:checked ~ label::before {
  opacity: 1;
}
.rating label {
  position: relative;
  margin-right: 6px;
  font-size: 5em;
  color: gold;
  cursor: pointer;
  transition: 0.5s;
}
.rating label:hover {
  -webkit-transform: scale(1.2);
          transform: scale(1.2);
}
.rating label::before {
  position: absolute;
  content: "\f384";
  opacity: 0;
  transition: 0.5s;
}
.rating label:hover::before, .rating label:hover ~ label::before {
  opacity: 1 !important;
}
.rating:hover input:checked ~ label::before {
  opacity: 0;
}
相关推荐
幼儿园技术家34 分钟前
原来不用发版也可以做到版本更新
前端·js or ts
亦暖筑序1 小时前
AgentScope-Java 入门:完善 Vue 前端、发布 GitHub,并规划下一步
java·前端·vue.js
北斗落凡尘1 小时前
Vue面试题
前端
程序员黑豆1 小时前
鸿蒙应用开发之父子组件传参:@Param、@Event、@Once 装饰器详解与实战
前端·harmonyos
ClouGence1 小时前
一个人录好的测试用例,团队怎么一起用?
前端·测试
无限压榨切图仔1 小时前
从 Claude Code 切到 Codex:我用 Agent、Skills、MCP 做完了一个内容运营工具
前端·后端
濮水大叔1 小时前
NestJS 与 CabloyJS 的 env/config 架构对比:从环境变量到实例级配置
前端·node.js·nestjs
成都渲染101云渲染66661 小时前
Blender渲染时,纯CPU渲染的设置教程
前端·javascript·blender
徐佳明1 小时前
从"能聊天"到"能干活":MCP Server 如何让 AI 智能体真正落地
css
董员外1 小时前
RAG 系统进化论(一):纵览 RAG 的发展历程
前端·人工智能·后端