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;
}
相关推荐
学习非暴力沟通的程序员19 分钟前
Karabiner-Elements 豆包语音输入一键启停操作手册
前端
Jing_Rainbow26 分钟前
【 前端三剑客-39 /Lesson65(2025-12-12)】从基础几何图形到方向符号的演进与应用📐➡️🪜➡️🥧➡️⭕➡️🛞➡️🧭
前端·css·html
刘羡阳30 分钟前
使用Web Worker的经历
前端·javascript
!执行38 分钟前
高德地图 JS API 在 Linux 系统的兼容性解决方案
linux·前端·javascript
Gooooo41 分钟前
现代浏览器的工作原理
前端
kk晏然1 小时前
TypeScript 错误类型检查,前端ts错误指南
前端·react native·typescript·react
纆兰1 小时前
汇款单的完成
前端·javascript·html
Lsx_2 小时前
案例+图解带你遨游 Canvas 2D绘图 Fabric.js🔥🔥(5W+字)
前端·javascript·canvas
m0_471199632 小时前
【场景】如何快速接手一个前端项目
前端·vue.js·react.js
榴莲CC2 小时前
抗干扰LED数显屏驱动VK1624 数码管显示芯片 3线串行接口
前端