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;
}
相关推荐
star010-7 分钟前
【视频+图文详解】HTML基础4-html标签的基本使用
前端·windows·经验分享·网络安全·html·html5
engchina13 分钟前
CSS Display属性完全指南
前端·css
engchina16 分钟前
详解CSS `clear` 属性及其各个选项
前端·css·css3
yashunan1 小时前
Web_php_unserialize
android·前端·php
m0_zj2 小时前
17.[前端开发]Day17-形变-动画-vertical-align
前端·css·chrome·html·html5
Edward-tan2 小时前
【玩转全栈】--创建一个自己的vue项目
前端·javascript·vue.js
青年夏日科技工作者2 小时前
虚幻浏览器插件 UE与JS通信
前端·javascript·html
雷神乐乐3 小时前
创建前端项目的方法
前端·javascript·vue.js
prince_zxill3 小时前
JavaScript面向对象编程:Prototype与Class的对比详解
前端·javascript·ecmascript·原型模式
D.eL4 小时前
Vue 2 项目中 Mock.js 的完整集成与使用教程
前端·javascript·vue.js