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;
}
相关推荐
前端snow21 分钟前
ai agent --- redis 缓存
前端
duanshu_1 小时前
官网表单与下载异常怎么排查?五个环节定位故障
前端·自动化·flyweight
Zhou1411361 小时前
SpringBoot_03_Web开发
前端·spring boot·python
辻弋2011 小时前
【无标题】
大数据·服务器·前端·搜索引擎·开源软件
FluxArt2 小时前
GPT Image 2.5 中文提示词教程:Flux Art 可复用模板
前端·gpt·算法
搬砖的小码农_Sky3 小时前
AI Agent:Windows上Node.js安装后 npm -v报错
前端·npm·node.js·人机交互
计算机魔术师3 小时前
半年翻倍!OpenAI再融300亿,估值冲到1.4万亿
前端
研☆香4 小时前
jQuery + Swiper.js 实现动态渲染轮播图
前端·javascript·jquery
子兮曰4 小时前
Node.js 50个优势场景盘点:一个人单干,为啥我多数时候只用它
前端·后端
IT_陈寒4 小时前
我花3小时debug,就因为JavaScript这个隐式转换坑
前端·人工智能·后端