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: #111;
  color: #fff;
  min-height: 100vh;
  display: grid;
  place-items: center;
  perspective: 420px;
  background-image: radial-gradient(circle, #ddd, #ddd0 20em), conic-gradient(#7bf, #7fb, #b7f, #bf7, #f7b, #fb7, #7bf);
  overflow: hidden;
}
body::after, body::before {
  content: "";
  position: absolute;
  inset: -100%;
  background-image: repeating-conic-gradient(#fff1 0 10deg, #fff0 0 20deg, #fff1 0 40deg, #fff0 0 55deg);
  z-index: -1;
  -webkit-animation: ray infinite linear;
          animation: ray infinite linear;
  -webkit-animation-duration: 30s;
          animation-duration: 30s;
}
body::before {
  -webkit-animation-duration: 60s;
          animation-duration: 60s;
  animation-direction: reverse;
}
@-webkit-keyframes ray {
  to {
    rotate: 1turn;
  }
}
@keyframes ray {
  to {
    rotate: 1turn;
  }
}
body *:not(:empty) {
  transform-style: preserve-3d;
}

.outer {
  position: relative;
  font-size: 42px;
  -webkit-animation: swingX 12s -12s infinite ease-in-out alternate;
          animation: swingX 12s -12s infinite ease-in-out alternate;
}
.outer .inner {
  -webkit-animation: swingY 12s -6s infinite ease-in-out alternate;
          animation: swingY 12s -6s infinite ease-in-out alternate;
}
.outer .inner::after {
  content: "";
  position: absolute;
  width: 12em;
  height: 10em;
  transform: translate(-50%, -50%);
  border: 2px solid plum;
  box-shadow: 0 0 1em purple, 0 0 1em palevioletred inset;
}
@-webkit-keyframes swingX {
  from {
    rotate: x -20deg;
  }
  to {
    rotate: x 20deg;
  }
}
@keyframes swingX {
  from {
    rotate: x -20deg;
  }
  to {
    rotate: x 20deg;
  }
}
@-webkit-keyframes swingY {
  from {
    rotate: y -20deg;
  }
  to {
    rotate: y 20deg;
  }
}
@keyframes swingY {
  from {
    rotate: y -20deg;
  }
  to {
    rotate: y 20deg;
  }
}
.outer .box {
  position: absolute;
  width: var(--w, 1em);
  height: var(--h, 1em);
  translate: calc(var(--tx, 0em) - 50%) calc(var(--ty, 0em) - 50%);
  -webkit-animation: boxRotate var(--duration) var(--delay1, 0s) infinite, boxScale 3s var(--delay2, 0s) infinite ease-in-out;
          animation: boxRotate var(--duration) var(--delay1, 0s) infinite, boxScale 3s var(--delay2, 0s) infinite ease-in-out;
}
@-webkit-keyframes boxScale {
  0%, 20%, 100% {
    scale: 1;
  }
  10% {
    scale: 0.7;
  }
}
@keyframes boxScale {
  0%, 20%, 100% {
    scale: 1;
  }
  10% {
    scale: 0.7;
  }
}
@-webkit-keyframes boxRotate {
  0% {
    transform: rotateX(0deg) rotateY(0deg);
  }
  10%, 25% {
    transform: rotateX(180deg) rotateY(0deg);
  }
  35%, 50% {
    transform: rotateX(180deg) rotateY(360deg);
  }
  60%, 75% {
    transform: rotateX(-180deg) rotateY(360deg);
  }
  85%, 100% {
    transform: rotateX(-180deg) rotateY(180deg);
  }
}
@keyframes boxRotate {
  0% {
    transform: rotateX(0deg) rotateY(0deg);
  }
  10%, 25% {
    transform: rotateX(180deg) rotateY(0deg);
  }
  35%, 50% {
    transform: rotateX(180deg) rotateY(360deg);
  }
  60%, 75% {
    transform: rotateX(-180deg) rotateY(360deg);
  }
  85%, 100% {
    transform: rotateX(-180deg) rotateY(180deg);
  }
}
.outer .box:nth-child(1) {
  --duration: 10.4620280703s;
  --delay1: -2.373306049s;
  --delay2: -0.7802613563s;
}
.outer .box:nth-child(2) {
  --duration: 9.6557531847s;
  --delay1: -6.3651977413s;
  --delay2: -2.0087508419s;
}
.outer .box:nth-child(3) {
  --duration: 9.6178248869s;
  --delay1: -5.8311745864s;
  --delay2: -2.6465083815s;
}
.outer .box:nth-child(4) {
  --duration: 9.1438862617s;
  --delay1: -6.4382773127s;
  --delay2: -0.9786783209s;
}
.outer .box:nth-child(5) {
  --duration: 9.3064854403s;
  --delay1: -8.178603008s;
  --delay2: -2.7738536635s;
}
.outer .box:nth-child(6) {
  --duration: 11.1596.........完整代码请登录后点击上方下载按钮下载查看

网友评论0