div+css实现三维彩色七环伸缩换位动画效果代码

代码语言:html

所属分类:动画

代码描述:div+css实现三维彩色七环伸缩换位动画效果代码

代码标签: div css 三维 彩色 七环 伸缩 换位 动画

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

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

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

  
  
  
<style>
*, *::before, *::after {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

body {
  background-color: #000;
  min-height: 100vh;
  display: grid;
  place-items: center;
  perspective: 800px;
  overflow: hidden;
}
body * {
  transform-style: preserve-3d;
}

.rings {
  position: relative;
  transform: rotateX(60deg);
}
.rings div {
  position: absolute;
  -webkit-animation: ringTranslate 14s var(--delay, 0s) infinite linear, ringScale 28s var(--delay, 0s) infinite, ease-in-out;
          animation: ringTranslate 14s var(--delay, 0s) infinite linear, ringScale 28s var(--delay, 0s) infinite, ease-in-out;
}
@-webkit-keyframes ringTranslate {
  0%, 100% {
    translate: 0 0 -12em;
  }
  90% {
    translate: 0 0 12em;
    -webkit-animation-timing-function: ease-in-out;
            animation-timing-function: ease-in-out;
  }
}
@keyframes ringTranslate {
  0%, 100% {
    translate: 0 0 -12em;
  }
  90% {
    translate: 0 0 12em;
    -webkit-animation-timing-function: ease-in-out;
            animation-timing-function: ease-in-out;
  }
}
@-webkit-keyframes ringScale {
  0%, 5%, 8%, 11.5%, 14.5%, 18%, 21%, 24.5%, 27.5%, 30.5%, 34%, 36.5%, 40.5%, 50%, 55%, 58%, 61.5%, 64.5%, 68%, 71%, 74.5%, 77.5%, 80.5%, 84%, 86.5%, 90.5% {
    scale: 1;
  }
  6%, 19%, 32%, 62.5%, 75.5%, 88.5% {
    scale: 1.3;
  }
  12.5%, 25.5%, 38.5%, 56%, 69%, 82% {
    scale: 0.7;
  }
}
@keyframes ringScale {
  0%, 5%, 8%, 11.5%, 14.5%, 18%, 21%, 24.5%, 27.5%, 30.5%, 34%, 36.5%, 40.5%, 50%, 55%, 58%, 61.5%, 64.5%, 68%, 71%, 74.5%, 77.5%, 80.5%, 84%, 86.5%, 90.5% {
    scale: 1;
  }
  6%, 19%, 32%, 62.5%, 75.5%, 88.5% {
    scale: 1.3;
  }
  12.5%, 25.5%, 38.5%, 56%, 69%, 82% {
    scale: 0.7;
  }
}
.rings div:nth-child(1) {
  --delay: 0s;
  --hue: 0;
}
.rings div:nth-child(2) {
  --delay: -16s;
  --hue: 51.4285714286;
}
.rings div:nth-child(3) {
  --delay: -32s;
  --hue: 102.8571428571;
}
.rings div:nth-child(4) {
  --delay: -48s;
  --hue: 154.2857142857;
}
.rings div:nth-child(5) {
  --delay: -64s;
  --hue: 205.7142857143;
}
.rings div:nth-child(6) {
  --delay: -80s;
  --hue: 257.1428571429;
}
.rings div:nth-child(7) {
  --delay: -96s;
  --hue: 308.5714285714;
}
.rings div i {
  --color: hsl(var(--hue, 0) 75% var(--light, 75%));
  --r: 0.8em;
  position: absolute;
  inset: -8em;
  background-image: radial-gradient(transparent, #0001 calc(6.8em - var(--r)), var(--color) 0 calc(7.2em + var(--r)), transparent 0);
  transform: translateZ(var(--translateZ, 0));
}
.rings div i:nth-child(1) {
  --translateZ: -16.5px;
  --light: 40%;
  --r: calc(sin(0deg) * 0.8em);
}
.rings div i:nth-child(2) {
  --translateZ: -13.5px;
  --light: 43%;
  --r: calc(sin(15deg) * 0.8em);
}
.rings div i:nth-child(3) {
  --translateZ: -10.5p.........完整代码请登录后点击上方下载按钮下载查看

网友评论0