css实现在彭罗斯三角形上移动的小球动画效果代码

代码语言:html

所属分类:动画

代码描述: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: flex;
  justify-content: center;
  align-items: center;
}

.penrose {
  position: relative;
  filter: drop-shadow(0 0 25px #000) drop-shadow(0 0 50px #43300a);
}

.triangle {
  position: absolute;
}
.triangle:nth-child(-n+3) {
  width: 146px;
  height: 36px;
  transform: translate(-50%, -50%) rotate(var(--aAngle)) translateX(31.4px) translateY(36px) skewX(-30deg);
  background-image: linear-gradient(to right, #000a, #0000 50%);
  -webkit-animation: triangleZ1 20s infinite step-end;
          animation: triangleZ1 20s infinite step-end;
}
@-webkit-keyframes triangleZ1 {
  0%, 85% {
    z-index: 2;
  }
  25% {
    z-index: -2;
  }
}
@keyframes triangleZ1 {
  0%, 85% {
    z-index: 2;
  }
  25% {
    z-index: -2;
  }
}
.triangle:nth-child(n+4) {
  width: 50px;
  height: 205px;
  transform: translate(-50%, -50%) rotate(var(--aAngle)) translateX(59.2px) translateY(-48.5px) skewX(30deg);
  background-image: linear-gradient(#000a, #0000 50%);
  -webkit-animation: triangleZ2 20s infinite step-end;
          animation: triangleZ2 20s infinite step-end;
}
@-webkit-keyframes triangleZ2 {
  0%, 50% {
    z-index: 2;
  }
  33.333% {
    z-index: -2;
  }
}
@keyframes triangleZ2 {
  0%, 50% {
    z-index: 2;
  }
  33.333% {
    z-index: -2;
  }
}
.triangle:nth-child(3n) {
  background-color: #df9f20;
  --aAngle: 0;
  -webkit-animation-delay: -6.6666666667s;
          animation-delay: -6.6666666667s;
}
.triangle:nth-child(3n+1) {
  background-color: #59400d;
  --aAngle: 120deg;
  -webkit-animation-delay: 0s;
          animation-delay: 0s;
}
.triangle:nth-child(3n+2) {
  background-color: #b3801a;
  --aAngle: 240deg;
  -webkit-animation-delay: -13.3333333333s;
          animation-delay: -13.3333333333s;
}

.ball {
  position: absolute;
  width: 30px;
  height: 30px;
  -webkit-animation: ball 20s infinite ease-in-out;
          animation: ball 20s infinite ease-in-out;
}
@-webkit-keyframes ball {
  0%, 100% {
    transform: translate(-50%, -50%) translateX(0px) translateY(-171px);
  }
  8.333% {
    transform: translate(-50%, -50%) translateX(110px) translateY(20px);
  }
  16.666% {
    transform: translate(-50%, -50%) translateX(-30px) translateY(20px);
  }
  25% {
    transform: translate(-50%, -50%) translateX(35px) translateY(-125px);
  }
  33.333% {
    transform: translate(-50%, -50%) translateX(148px) translateY(90px);
  }
  41.666% {
    transform: translate(-50%, -50%) translateX(-80px) translateY(90px);
  }
  50% {
    transform: translate(-50%, -50%) translateX(0px) translateY(-50px);
  }
  58.333% {
    transform: transl.........完整代码请登录后点击上方下载按钮下载查看

网友评论0