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;
}
相关推荐
华科云商xiao徐3 分钟前
利用Python requests库爬虫程序示例
前端
艾克马斯奎普特4 分钟前
一篇文章彻底讲透 CSS 的属性值计算过程,包含选择器优先级、层叠和继承
前端·css
wordbaby4 分钟前
JSON.parse(JSON.stringify()) 的“坑”:数据丢失与类型转换问题
前端·json
webxin6665 分钟前
微信端视频自动播放的兼容方案
前端·javascript
小钰能吃三碗饭5 分钟前
第二篇:【前端进阶之道】现代 JavaScript 高级特性实战指南
前端·javascript·typescript
前端没钱6 分钟前
uni-app使用web-view传参的坑
前端
kovli8 分钟前
红宝书第三讲:JavaScript 操作符与流程控制详解
前端·javascript
蓝色的猴子12 分钟前
JS 中html的document
前端·javascript·html
倒霉男孩17 分钟前
新HTML5
前端·html·html5
伟笑1 小时前
elementui table禁用全选,一次限制勾选一项。
前端·javascript·elementui