1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| body { overflow: hidden; height: 100vh; perspective: 20em; } div { position: absolute; } .cube { top: calc(50% - 5em); left: calc(50% - 5em); transform-style: preserve-3d; } body:hover .cube { animation: r 4s linear infinite; } .cube__face { width: 10em; height: 10em; box-shadow: 0 0 0 1px; } .cube__face:nth-child(1) { transform: rotateY(0deg) translateZ(5em); } .cube__face:nth-child(2) { transform: rotateY(90deg) translateZ(5em); } .cube__face:nth-child(3) { transform: rotateY(180deg) translateZ(5em); } .cube__face:nth-child(4) { transform: rotateY(270deg) translateZ(5em); } .cube__face:nth-child(5) { transform: rotateX(90deg) translateZ(5em); } .cube__face:nth-child(6) { transform: rotateX(-90deg) translateZ(5em); } @keyframes r { to { transform: rotateY(1turn); } }
|