Folding Cube Animation
Home
Snippets
Folding Cube Animation
HTML
CSS
JS
<div class="cube-wrapper"> <div class="cube"></div> <div class="cube"></div> <div class="cube"></div> <div class="cube"></div> </div>
body { margin: 0; height: 100vh; background: #0f172a; display: flex; justify-content: center; align-items: center; } .cube-wrapper { width: 60px; height: 60px; position: relative; transform: rotateZ(45deg); perspective: 800px; } .cube { position: absolute; width: 50%; height: 50%; background: linear-gradient(135deg, #00ffc3, #00bfa6); opacity: 0.9; animation: foldCube 2.4s infinite ease-in-out; transform-origin: center center; border-radius: 4px; } .cube:nth-child(1) { top: 0; left: 0; transform-origin: 100% 100%; animation-delay: 0s; } .cube:nth-child(2) { top: 0; left: 50%; transform-origin: 0% 100%; animation-delay: 0.3s; } .cube:nth-child(3) { top: 50%; left: 0; transform-origin: 100% 0%; animation-delay: 0.6s; } .cube:nth-child(4) { top: 50%; left: 50%; transform-origin: 0% 0%; animation-delay: 0.9s; } @keyframes foldCube { 0%, 10% { transform: rotateX(0deg) rotateY(0deg); opacity: 1; } 25% { transform: rotateX(180deg) rotateY(0deg); opacity: 0.4; } 50%, 100% { transform: rotateX(0deg) rotateY(0deg); opacity: 1; } }
//javascript
Ad #1
Ad #2
Scroll to Top