react实现带提示的分段进度条效果代码

代码语言:html

所属分类:进度条

代码描述:react实现带提示的分段进度条效果代码

代码标签: react 提示 分段 进度条

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

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

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

  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  
  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=DM+Sans&amp;display=swap'>
  
<style>
* {
  border: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --hue: 223;
  --bg: hsl(var(--hue),90%,90%);
  --fg: hsl(var(--hue),90%,10%);
  --primary: hsl(var(--hue),90%,50%);
  --trans-dur: 0.3s;
  --ease-in-out: cubic-bezier(0.65,0,0.35,1);
  --ease-in-out-back: cubic-bezier(0.65,-0.35,0.35,1.35);
  font-size: calc(14px + (30 - 14) * (100vw - 280px) / (3840 - 280));
}

body {
  background-color: var(--bg);
  color: var(--fg);
  display: flex;
  font: 1em/1.5 "DM Sans", sans-serif;
  height: 100vh;
  transition: background-color var(--trans-dur), color var(--trans-dur);
}

.checkmark {
  display: block;
  width: 1em;
  height: 1em;
}

.dots {
  --dur: 1s;
  background-color: white;
  border-radius: 50%;
  position: relative;
  width: 0.375em;
  height: 0.375em;
}
.dots, .dots:before, .dots:after {
  animation: dot-fade var(--dur) calc(var(--dur) * -0.125) linear infinite;
}
.dots:before, .dots:after {
  background-color: inherit;
  border-radius: inherit;
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
}
.dots:before {
  animation-delay: calc(var(--dur) * -0.25);
  transform: translateX(-125%);
}
.dots:after {
  animation-delay: 0s;
  transform: translateX(125%);
}

.progress {
  background-color: white;
  border-radius: 1em;
  box-shadow: 0 0 1em rgba(0, 0, 0, 0.3);
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 2.5625em auto 0;
  width: calc(100% - 3em);
  min-width: 16em;
  max-width: 30em;
  height: 3em;
  transform: translate(-50%, -50%);
  transition: background-color var(--trans-dur);
}
.progress__container {
  border-radius: inherit;
  display: flex;
  overflow: hidden;
  height: 100%;
}
.progress__step {
  display: grid;
  place-items: center;
  padding-inline: 1.125em 0;
  position: relative;
  width: 100%;
}
.progress__step:after {
  aspect-ratio: 1/1;
  background-color: var(--primary);
  border-radius: 0.5em;
  box-shadow: 0 0 0 1px white;
  content: "";
  display: block;
  opacity: 0;
  position: absolute;
  top: 0;
  right: -0.75em;
  width: 150%;
  height: auto;
  transform: rotate(45deg);
  transform-origin: calc(100% - 1.5em) 1.5em;
  transition: background-color var(--trans-dur), box-shadow var(--trans-dur), opacity var(--trans-dur);
  z-index: -1;
}
[dir=rtl] .progress__step:after {
  right: auto;
  left: -0.75em;
  transform: rotate(-45deg);
  transform-origin: 1.5em 1.5em;
}
.progress__step--active {
  color: white;
}
.progress__step--active:after {
  opacity: 1;
}
.progress__step:nth-child(1) {
  z-index: -1;
}
.progress__step:nth-child(2) {
  z-index: -2;
}
.progress__step:nth-child(3) {
  z-index: -3;
}
.progress__step:nth-child(4) {
  z-index: -4;
}
.progress__step:nth-child(5) {
  z-index: -5;
}
.progress__tip {
  animation: tip-fade-in var(--trans-dur) var(--ease-in-out) forwards;
  border-radius: 1.875em;
  color: hsl(var(--hue), 90%, 90%);
  display: grid;
  place-items: center;
  padding: 0 1em;
  position: absolute;
  bottom: 100%;
  left: 0.5625em;
  margin-bottom: 1.5em;
  min-width: 3.75em;
  height: 3.75em;
  transform: translateX(-50%);
  transition: background-color var(--trans-dur), color var(--trans-dur), margin-inline-start var(--trans-dur) var(--ease-in-out-back);
  white-space: nowrap;
}
.progress__tip, .progress__tip:after {
  background-color: hsl(var(--hue), 90%, 10%);
}
.progress__tip:after {
  border-radius: 0.125em 0 0;
  content: "";
  display: block;
  position: absolute;
  top: calc(100% - 0.125em);
  left: 50%;
  width: 1em;
  height: 1em;
  transform: translate(-50%, -50%) rotate(225deg);
  transition: inherit;
}
.progress__tip--out {
  animation-name: tip-fade-out !important;
}
[dir=rtl] .progress__tip--out {
  animation-name: tip-fade-out-rtl !important;
}
[dir=rtl] .progress__tip {
  animation-name: tip-fade-in-rtl;
  right: 0.5625em;
  left: auto;
  transform: translateX(50%);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: hsl(var(--hue),90%,10%);
    --fg: hsl(var(--hue),90%,90%);
  }

  .progress {
    background-color: hsl(var(--hue), 90%, 20%);
  }
  .progress__step::after {
    box-shadow: 0 0 0 1px hsl(var(--hue), 90%, 20%);
  }
  .progress__tip {
    color: hsl(var(--hue), 90%, 10%);
  }
  .progress__tip, .progress__tip:after {
    background-color: hsl(var(--hue), 90%, 90%);
  }
}
/* Animtions */
@keyframes dot-fade {
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0