css实现多米诺骨牌动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现多米诺骨牌动画效果代码

代码标签: 动画 效果

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


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

<head>

  <meta charset="UTF-8">

  
  
  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap");
*, *::before, *::after {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

body {
  font-family: "Indie Flower", cursive;
  background-color: #333;
  color: #fff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  position: relative;
  width: 900px;
  height: 600px;
  border: 2px solid #fff;
  background-image: linear-gradient(#456, #333 75%, #444 75%, #222);
  perspective: 400px;
  overflow: hidden;
}
.container h1 {
  font-size: 60px;
  font-weight: normal;
  text-align: center;
  padding: 2em 0.5em;
  line-height: 0.75;
}

.floor {
  position: absolute;
  bottom: 0px;
  width: 200px;
  height: 400px;
  background-color: #0003;
  transform: rotateX(90deg);
  transform-origin: bottom;
  -webkit-animation: floors 16s infinite linear;
          animation: floors 16s infinite linear;
}
.floor:nth-child(1) {
  -webkit-animation-delay: -2.31s;
          animation-delay: -2.31s;
}
.floor:nth-child(2) {
  -webkit-animation-delay: -4.31s;
          animation-delay: -4.31s;
}
.floor:nth-child(3) {
  -webkit-animation-delay: -6.31s;
          animation-delay: -6.31s;
}
.floor:nth-child(4) {
  -webkit-animation-delay: -8.31s;
          animation-delay: -8.31s;
}
.floor:nth-child(5) {
  -webkit-animation-delay: -10.31s;
          animation-delay: -10.31s;
}
.floor:nth-child(6) {
  -webkit-animation-delay: -12.31s;
          animation-delay: -12.31s;
}
.floor:nth-child(7) {
  -webkit-animation-delay: -14.31s;
          animation-delay: -14.31s;
}
.floor:nth-child(8) {
  -webkit-animation-delay: -16.31s;
          animation-delay: -16.31s;
}
@-webkit-keyframes floors {
  from {
    left: calc(50% - 1500px);
  }
  to {
    left: calc(50% + 1700px);
  }
}
@keyframes floors {
  from {
    left: calc(50% - 1500px);
  }
  to {
    left: calc(50% + 1700px);
  }
}

.shadow {
  position: absolute;
  bottom: 0px;
  width: 60px;
  height: 400px;
  background-image: radial-gradient(#222, transparent 60%);
  transform: rotateX(90deg) translateX(40px) scaleX(-1);
  transform-origin: bottom left;
  -webkit-animation: shadows 8s infinite linear;
          animation: shadows 8s infinite linear;
}
.shadow:nth-child(1) {
  -webkit-animation-delay: -0.5s;
          animation-delay: -0.5s;
}
.shadow:nth-child(2) {
  -webkit-animation-delay: -1s;
          animation-delay: -1s;
}
.shadow:nth-child(3) {
  -webkit-animation-delay: -1.5s;
          animation-delay: -1.5s;
}
.shadow:nth-child(4) {
  -webkit-animation-delay: -2s;
          animation-delay: -2s;
}
.shadow:nth-child(5) {
  -webkit-animation-delay: -2.5s;
          animation-delay: -2.5s;
}
.shadow:nth-child(6) {
  -webkit-animation-delay: -3s;
          animation-delay: -3s;
}
.shadow:nth-child(7) {
  -webkit-animation-delay: -3.5s;
          animation-delay: -3.5s;
}
.shadow:nth-child(8) {
  -webkit-animation-delay: -4s;
          animation-delay: -4s;
}
.shadow:nth-child(9) {
  -webkit-animation-delay: -4.5s;
          animation-delay: -4.5s;
}
.shadow:nth-child(10) {
  -webkit-animation-delay: -5s;
          animation-delay: -5s;
}
.shadow:nth-child(11) {
  -webkit-animation-delay: -5.5s;
          animation-delay: -5.5s;
}
.shadow:nth-child(12) {
  -webkit-animation-delay: -6s;
          animation-delay: -6s;
}
.shadow:nth-child(13) {
  -webkit-animation-delay: -6.5s;
          animation-delay: -6.5s;
}
.shadow:nth-child(14) {
  -webkit-animation-delay: -7s;
          animation-delay: -7s;
}
.shadow:nth-child(15) {
  -webkit-animation-delay: -7.5s;
          animation-delay: -7.5s;
}
.shadow:nth-child(16) {
  -webkit-animation-delay: -8s;
          animation-delay: -8s;
}
@-webkit-keyframes shadows {
  from {
    left: calc(50% - 700px);
  }
  to {
    left: calc(50% + 900px);
  }
  0%, 43.75% {
    transform: rotateX(90deg) translateX(40px) scaleX(-1);
  }
  100% {
    transform: rotateX(90deg) translateX(40px) scaleX(-7);
  }
}
@keyframes shadows {
  from {
    left: calc(50% - 700px);
  }
  to {
    left: calc(50% + 900px);
  }
  0%, 43.75% {
    transform: rotateX(90deg) translateX(40px) scaleX(-1);
  }
  100% {
    transform: rotateX(90deg) translateX(40px) scaleX(-7);
  }
}

.domino {
  position: absolute;
  bottom: 0px;
  width: 20px;
  height: 400px;
  transform: rotateX(90deg);
  transform-origin: bottom left;
  transform-style: preserve-3d;
  -webkit-animation: domino 8s infinite linear;
          animation: domino 8s infinite linear;
}
.domino:nth-child(1) {
  -webkit-animation-delay: -0.5s;
          animation-delay: -0.5s;
}
.domino:nth-child(1) * {
  position: absolute;
  background-color: #E57373;
}
.domino:nth-child(2) {
  -webkit-animation-delay: -1s;
          animation-delay: -1s;
}
.domino:nth-child(2) * {
  position: absolute;
  background-color: #F06292;
}
.domino:nth-child(3) {
  -webkit-animation-delay: -1.5s;
          animation-delay: -1.5s;
}
.domino:nth-child(3) * {
  position: absolute;
  background-color: #BA68C8;
}
.domino:nth-child(4) {
  -webkit-animation-delay: -2s;
          animation-delay: -2s;
}
.domino:nth-child(4) * {
  position: absolute;
  background-color: #9575CD;
}
.domino:nth-child(5) {
  -webkit-animation-delay: -2.5s;
          animation-delay: -2.5s;
}
.domino:nth-child(5) * {
  position: absolute;
  background-color: #7986CB;
}
.domino:nth-child(6) {
  -webkit-animation-delay: -3s;
          animation-delay: -3s;
}
.domino:nth-child(6) * {
  position: absolute;
  background-color: #64B5F6;
}
.domino:nth-child(7) {
  -webkit-animation-delay: -3.5s;
          animation-delay: -3.5s;
}
.domino:nth-child(7) * {
  position: absolute;
  background-color: #4FC3F7;
}
.domino:nth-child(8) {
  -webkit-animation-delay: -4s;
          animation-delay: -4s;
}
.domino:nth-child(8) * {
  position: absolute;
  background-color: #4DD0E1;
}
.domino:nth-child(9) {
  -webkit-animation-delay: -4.5s;
          animation-delay: -4.5s;
}
.domino:nth-child(9) * {
  position: absolute;
  background-color: #4DB6AC;
}
.domino:nth-child(10) {
  -webkit-animation-delay: -5s;
          animation-delay: -5s;
}
.domino:nth-child(10) * {
  position: absolute;
  background-color: #81C784;
}
.domino:nth-child(11) {
  -webkit-animation-delay: -5.5s;
          animation-delay: -5.5s;
}
.domino:nth-child(11) * {
  position: absolute;
  background-color: #AED581;
}
.domino:nth-child(12) {
  -webkit-animation-delay: -6s;
          animation-delay: -6s;
}
.domino:nth-child(12) * {
  position: absolute;
  background-color: #DCE775;
}
.domino:nth-child(13) {
  -webkit-animation-delay: -6.5s;
          animation-delay: -6.5s;
}
.domino:nth-child(13) * {
  position: absolute;
  background-color: #FFF176;
}
.domino:nth-child(14) {
  -webkit-animation-delay: -7s;
          animation-delay: -7s;
}
.domino:nth-child(14) * {
  position: absolute;
  background-color: .........完整代码请登录后点击上方下载按钮下载查看

网友评论0