纯css实现的星级评分打分动画效果代码

代码语言:html

所属分类:星级评分

代码描述:纯css实现的星级评分打分动画效果代码

代码标签: css 星级 评分 打分 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">

  
<style>
@charset "UTF-8";
:root {
  --enlarge: scale(1.25);
  --page-color: steelblue;
  --star-primary-color: gold;
  --star-secondary-color: darkgoldenrod;
}

body {
  background: var(--page-color);
  margin: 0;
  font-family: system-ui;
}

.container {
  display: grid;
  min-height: 100vh;
  place-content: center;
}

.star-group {
  display: grid;
  font-size: clamp(1.5em, 10vw, 8em);
  grid-auto-flow: column;
}

/* reset native input styles */
.star {
  -webkit-appearance: none;
  align-items: center;
  appearance: none;
  cursor: pointer;
  display: grid;
  font: inherit;
  height: 1.15em;
  justify-items: center;
  margin: 0;
  place-content: center;
  position: relative;
  width: 1.15em;
}

@media (prefers-reduced-motion: no-preference) {
  .star {
    transition: all 0.25s;
  }

  .star:before,
.star:after {
    transition: all 0.25s;
  }
}
.star:before,
.star:after {
  color: var(--star-primary-color);
  position: absolute;
}

.star:before {
  content: "☆";
}

.star:after {
  content: "✦";
  font-size: 25%;
  opacity: 0;
  right: 20%;
  top: 20%;
}

/* The checked radio button and each radio button preceding */
.star:checked:before,
.star:has(~ .star:checked):before {
  content: "★";
}

#two:checked:after,
.star:has(~ #two:checked):after {
  opacity: 1;
  right: 14%;
  top: 10%;
}

#three:checked:before,
.star:has(~ #three:checked):before {
  transform: var(--enlarge);
}

#three:checked:after,
.star:has(~ #three:checked):after {
  opacity: 1;
  right: 8%;
  top: 2%;
  transform: var(--enlarge);
}

#four:checked:before,
.star:has(~ #four:checked):before {
  text-shadow: 0.05em 0.033em 0px var(--star-secondary-color);
  transform: var(--enlarge);.........完整代码请登录后点击上方下载按钮下载查看

网友评论0