div+css实现星级评分效果代码

代码语言:html

所属分类:星级评分

代码描述:div+css实现星级评分效果代码,全程无js代码,通过css实现。

代码标签: div css 星级 评分

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

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

<head>
  <meta charset="UTF-8">
  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.css">

  
  
<style>
@charset "UTF-8";
html {
  --ctx-bg: #1d122f;
  --ctx-color: #f0f1f4;
  --accent: #ffe4c2;
  --highlight: #ff0196;
  height: 100%;
  background-color: var(--ctx-bg);
  background-image: linear-gradient(-30deg, var(--ctx-bg), #560e49);
}

body {
  display: flex;
  flex-direction: column;
  gap: 1em;
  justify-content: center;
  align-items: center;
  min-height: 100%;
  color: var(--ctx-color);
}

*, *::before, *::after {
  box-sizing: border-box;
}

.visuhide {
  position: absolute !important;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip: rect(1px, 1px, 1px, 1px);
}

.star-item .star-container:hover, .star-radio:checked ~ .star-item {
  filter: grayscale(0);
}

.star-item:hover ~ .star-item, .star-item, .star-container:not(:hover) > .star-radio:nth-of-type(5):checked ~ .star-item:nth-of-type(5) ~ .star-item, .star-container:not(:hover) > .star-radio:nth-of-type(4):checked ~ .star-item:nth-of-type(4) ~ .star-item, .star-container:not(:hover) > .star-radio:nth-of-type(3):checked ~ .star-item:nth-of-type(3) ~ .star-item, .star-container:not(:hover) > .star-radio:nth-of-type(2):checked ~ .star-item:nth-of-type(2) ~ .star-item, .star-container:not(:hover) > .star-radio:nth-of-type(1):checked ~ .star-item:nth-of-type(1) ~ .star-item {
  filter: grayscale(1) opacity(0.75);
}

.star-container {
  position: static;
  padding: 1em;
  text-align: center;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  border: 0;
  border-radius: 0.25em;
  box-shadow: inset 0 1px 0 rgba(255, 228, 194, 0.25), inset 0 0.25em 1em rgba(86, 14, 73, 0.5), 0 4px 4px rgba(0, 0, 0, 0.3828125), 0 8px 8px rgba(0, 0, 0, 0.28125), 0 12px 12px rgba(0, 0, 0, 0.1953125), 0 16px 16px rgba(0, 0, 0, 0.125), 0 20px 20px rgba(0, 0, 0, 0.0703125), 0 24px 24px rgba(0, 0, 0, 0.03125), 0 28px 28px rgba(0, 0, 0, 0.0078125);
  background: linear-gradient(to bottom, #2b1136, var(--ctx-bg)) var(--ctx-bg);
  background-origin: border-box;
}
.star-legend {
  position: static;
  display: block;
  margin: auto;
  -webkit-padding-after: 1em;
          padding-block-end: 1em;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 100;
  letter-spacing: 0.125em;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 1px 2px black;
  translate: 0 100%;
}
.star-radio:nth-of-type(1):checked ~ .star-item:nth-of-type(1)::before {
  transform: scale(1.5);
  transition-timing-function: cubic-bezier(0.5, 1.5, 0.25, 1);
}
.star-radio:nth-of-type(2):check.........完整代码请登录后点击上方下载按钮下载查看

网友评论0