st.scss 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. $n:5; /* number of images*/
  2. .gallery {
  3. --d: 10s; /* duration */
  4. display: grid;
  5. width: 220px;
  6. }
  7. .gallery > img {
  8. grid-area: 1/1;
  9. width: 100%;
  10. aspect-ratio: 1;
  11. object-fit: cover;
  12. border: 10px solid #f2f2f2;
  13. box-shadow: 0 0 4px #0007;
  14. z-index: 2;
  15. animation:
  16. slide var(--d) infinite,
  17. z-order var(--d) infinite steps(1);
  18. }
  19. .gallery img:last-child {
  20. animation-name: slide, z-order-last;
  21. }
  22. @for $i from 1 to ($n + 1) {
  23. .gallery > img:nth-child(#{$i}) {
  24. animation-delay: calc(#{(1 - $i)/$n}*var(--d));
  25. --r: #{(-20 + random(40))*1deg};
  26. }
  27. }
  28. @keyframes slide {
  29. 16.67% { transform: translateX(120%) rotate(var(--r))}
  30. 33.33% { transform: translateX(0%) rotate(var(--r))}
  31. }
  32. @keyframes z-order {
  33. 16.67%,
  34. 33.33% { z-index: 1; }
  35. 66.33% { z-index: 2; }
  36. }
  37. @keyframes z-order-last {
  38. 16.67%,
  39. 33.33% { z-index: 1; }
  40. 83.33% { z-index: 2; }
  41. }
  42. body {
  43. margin: 0;
  44. min-height: 100vh;
  45. display: grid;
  46. place-content: center;
  47. background: #CDB380;
  48. overflow: hidden;
  49. }