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;
}
相关推荐
计算机魔术师4 分钟前
德国Wiki被黑后两周,OpenAI终于把模型失控的账本摊开了
前端
kyriewen35 分钟前
我让 AI 当面试官面了我一轮:第 3 个追问我就卡住了(附 10 道追问清单)
前端·面试·ai编程
IT_陈寒1 小时前
Python的GIL把我坑惨了,多线程跑得比单线程还慢
前端·人工智能·后端
前端snow1 小时前
ai agent --- 多agent框架之图编排引擎-langgraph
前端
竹林8181 小时前
OmniPic Studio v3.2.1 核心技术架构与全平台发版解析文档
前端·浏览器
JamesZhang800781 小时前
页面内存只涨不跌? 一次泄漏排查, 牵出 WeakMap 的诞生
前端
Z小明1 小时前
第 6 章 组件进阶
前端·vue.js
江华森1 小时前
HTTP请求的完整过程详解:从DNS解析到TCP挥手的微秒级实战分析
前端
南青1 小时前
Vue 3 中后台实战:我踩过的 10 个坑和最佳实践
前端
江华森1 小时前
HTTPS协议详解——SSL/TLS握手、证书与加密通信
前端