css实现一个五角变换动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现一个五角变换动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <style> *, *::before, *::after { padding: 0; margin: 0 auto; box-sizing: border-box; transform-style: preserve-3d; } body { background-image: radial-gradient(circle, #222, #000 20em); color: #fff; min-height: 100vh; display: flex; justify-content: center; align-items: center; perspective: 750px; overflow: hidden; } .scene { position: relative; -webkit-animation: scene 24s infinite linear; animation: scene 24s infinite linear; } @-webkit-keyframes scene { 0% { transform: rotateY(360deg) rotateX(-45deg); } 100% { transform: rotateY(0deg) rotateX(-45deg); } } @keyframes scene { 0% { transform: rotateY(360deg) rotateX(-45deg); } 100% { transform: rotateY(0deg) rotateX(-45deg); } } .pentagon { position: absolute; width: 8em; height: 0.32em; -webkit-animation: sqr 12s infinite linear; animation: sqr 12s infinite linear; } @-webkit-keyframes sqr { 0% { top: -16em; transform: translate(-50%, -50%) rotateY(0deg); } 100% { top: 16em; transform: translate(-50%, -50%) rotateY(-144deg); } } @keyframes sqr { 0% { top: -16em; transform: translate(-50%, -50%) rotateY(0deg); } 100% { top: 16em; transform: translate(-50%, -50%) rotateY(-144deg); } } .pentagon:nth-child(1) { -webkit-animation-delay: 0s; animation-delay: 0s; } .pentagon:nth-child(2) { -webkit-animation-delay: -0.375s; animation-delay: -0.375s; } .pentagon:nth-child(3) { -webkit-animation-delay: -0.75s; animation-delay: -0.75s; } .pentagon:nth-child(4) { -webkit-animation-delay: -1.125s; animation-delay: -1.125s; } .pentagon:nth-child(5) { -webkit-animation-delay: -1.5s; animation-delay: -1.5s; } .pentagon:nth-child(6) { -webkit-animation-delay: -1.875s; animation-delay: -1.875s; } .pentagon:nth-child(7) { -webkit-animation-delay: -2.25s; animation-delay: -2.25s; } .pentagon:nth-child(8) { -webkit-animation-delay: -2.625s; animation-delay: -2.625s; } .pentagon:nth-child(9) { -webkit-animation-delay: -3s; animation-delay: -3s; } .pentagon:nth-child(10) { -webkit-animation-delay: -3.375s; animation-delay: -3.375s; } .pentagon:nth-child(11) { -webkit-animation-delay: -3.75s; animation-delay: -3.75s; } .pentagon:nth-child(12) { -webkit-animation-delay: -4.125s; animation-delay: -4.125s; } .pentagon:nth-child(13) { -webkit-animation-delay: -4.5s; animation-delay: -4.5s; } .pentagon:nth-child(14) { -webkit-animation-delay: -4.875s; animation-delay: -4.875s; } .pentagon:nth-child(15) { -webkit-animation-delay: -5.25s; animation-delay: -5.25s; } .pentagon:nth-child(16) { -webkit-animation-delay: -5.625s; animation-delay: -5.625s; } .pentagon:nth-child(17) { -webkit-animation-delay: -6s; animation-delay: -6s; } .pentagon:nth-child(18) { -webkit-animation-delay: -6.375s; animation-delay: -6.375s; } .pentagon:nth-child(19) { -webkit-animation-delay: -6.75s; animation-delay: -6.75s; } .pentagon:nth-child(20) { -webkit-animation-delay: -7.125s; animation-delay: -7.125s; } .pentagon:nth-child(21) { -webkit-animation-delay: -7.5s; animation-delay: -7.5s; } .pentagon:nth-child(22) { -webkit-animation-delay: -7.875s; animation-delay: -7.875s; } .pentagon:nth-child(23) { -webkit-animation-delay: -8.25s; animation-delay: -8.25s; } .pentagon:nth-child(24) { -webkit-animation-delay: -8.625s; animation-delay: -8.625s; } .pentagon:nth-child(25) { -webkit-animation-delay: -9s; animation-delay: -9s; } .pentagon:nth-child(26) { -webkit-animation-delay: -9.375s; animation-delay: -9.375s; } .pentagon:nth-child(27) { -webkit-animation-delay: -9.75s; animation-delay: -9.75s; } .pentagon:nth-child(28) { -webkit-animation-delay: -10.125s; animation-delay: -10.125s; } .pentagon:nth-child(29) { -webkit-animation-delay: -10.5s; animation-delay: -10.5s; } .pentagon:nth-child(30) { -webkit-animation-delay: -10.875s; animation-delay: -10.875s; } .pentagon:nth-child(31) { -webkit-animation-delay: -11.25s; animation-delay: -11.25s; } .pentagon:nth-child(32) { -webkit-animation-delay: -11.625s; animation-delay: -11.625s; } .side { position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; background-image: linear-gradient(90deg, #333, #633); -webkit-animation: side 12s infinite ease-in-out; animation: side 12s infinite ease-in-out; -webkit-animation-delay: inherit; animation-delay: inherit; } .side:nth-child(1) { --sideAngle: 0deg; } .side:nth-child(2) { --sideAngle: 72deg; } .side:nth-child(3) { --sideAngle: 144deg; } .side:nth-child(4) { --sideAngle: 216deg; } .side:nth-child(5) { --sideAngle: 288deg; } @-webkit-keyframes side { 0% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(0em) scaleX(0); } 25% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(5.5em) scaleX(1); } 50% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(0.55em) scaleX(0.1); } 75% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(5.5em) scaleX(1); } 100% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(0em) scaleX(0); } } @keyframes side { 0% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(0em) scaleX(0); } 25% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(5.5em) scaleX(1); } 50% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(0.55em) scaleX(0.1); } 75% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(5.5em) scaleX(1); } 100% { transform: translate(-50%, -50%) rotateY(var(--sideAngle)) translateZ(0em) scaleX(0); } } .side::after { content: ""; position: absolute; width: 100%; height: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; background-image: linear-gradient(90deg, #fff, #faa); } </style> </head> <body> <div class="scene"> <div class="pentagon"> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> </div> <div class="pentagon"> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> </div> <div class="pentagon"> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> </div> <div class="pentagon"> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> </div> <div class="pentagon"> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> <div class="side"></div> </div> <div class="pentagon"> <div class="side"></div> <div class="side"></div> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0