Пример:
HTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<div class="d-container"> <div class="d-cube"> <figure> <img src="photo-1.jpg" alt="photo"> </figure> <figure> <img src="photo-2.jpg" alt="photo"> </figure> <figure> <img src="photo-3.jpg" alt="photo"> </figure> <figure> <img src="photo-4.jpg" alt="photo"> </figure> <figure> <img src="photo-5.jpg" alt="photo"> </figure> <figure> <img src="photo-6.jpg" alt="photo"> </figure> </div> </div> |
CSS:
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
.d-container{ margin: 30px auto; width: 300px; height: 300px; position: relative; perspective: 1000px; } .d-cube { width: 100%; height: 100%; position: absolute; transform-style: preserve-3d; transform: translateZ(-150px) rotateY(0deg); animation: cube 12s infinite; } .d-cube figure { width: 100%; height: 100%; margin: 0; position: absolute; } .d-cube figure img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center center; } figure:nth-child(1) { transform: rotateY(0deg) translateZ(150px); } figure:nth-child(2) { transform: rotateX(180deg) translateZ(150px); } figure:nth-child(3) { transform: rotateY(90deg) translateZ(150px); } figure:nth-child(4) { transform: rotateY(-90deg) translateZ(150px); } figure:nth-child(5) { transform: rotateX(90deg) translateZ(150px); } figure:nth-child(6){ transform: rotateX(-90deg) translateZ(150px); } @keyframes cube { 0% { transform: translateZ(-150px) rotateY(0deg); } 16.66% { transform: translateZ(-150px) rotateX(-180deg); } 33.32% { transform: translateZ(-150px) rotateY(-90deg); } 50% { transform: translateZ(-150px) rotateY(90deg); } 66.66% { transform: translateZ(-150px) rotateX(-90deg); } 83.32% { transform: translateZ(-150px) rotateX(90deg); } 100% { transform: translateZ(-150px) rotateY(0deg); } } |
Добавить комментарий: