.gallery { --d: 10s; display: grid; width: 27.098vw; margin-left: 5.088vw; } .gallery > .pets-img { grid-area: 1/1; width: 100%; aspect-ratio: 1; object-fit: cover; border: 10px solid #f2f2f2; box-shadow: 0 0 4px rgba(0, 0, 0, 0.4666666667); z-index: 2; animation: slide var(--d) infinite, z-order var(--d) infinite steps(1); } .gallery .pets-img:last-child { animation-name: slide, z-order-last; } .gallery > .pets-img:nth-child(1) { animation-delay: calc(0 * var(--d)); --r: -17deg; } .gallery > .pets-img:nth-child(2) { animation-delay: calc(-0.2 * var(--d)); --r: 1deg; } .gallery > .pets-img:nth-child(3) { animation-delay: calc(-0.4 * var(--d)); --r: 16deg; } .gallery > .pets-img:nth-child(4) { animation-delay: calc(-0.6 * var(--d)); --r: 19deg; } .gallery > .pets-img:nth-child(5) { animation-delay: calc(-0.8 * var(--d)); --r: -13deg; } @keyframes slide { 16.67% { transform: translateX(90%) rotate(var(--r)); } 33.33% { transform: translateX(0%) rotate(var(--r)); } } @keyframes z-order { 16.67%, 33.33% { z-index: 1; } 66.33% { z-index: 2; } } @keyframes z-order-last { 16.67%, 33.33% { z-index: 1; } 83.33% { z-index: 2; } } /* body { margin: 0; min-height: 100vh; display: grid; place-content: center; background: #CDB380; overflow: hidden; } */