Blossom Carousel Logo
Advanced

Smart Stack

Build an iOS-like smart stack.
1
2
3
4
5
6
7
8
9
10
.widget {
  width: 160px;
  height: 160px;
  overflow: clip;
  background: red;
  border-radius: 2rem;
}

.smart-stack {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  height: 100%;
  scroll-snap-type: x mandatory;

  & .slide {
    view-timeline: --slide inline 30%;

    & .slide-content {
      animation: slide cubic-bezier(0, 0.5, 1, 0.5) both;
      animation-timeline: --slide;
      animation-range: cover;
    }
  }
}

.slide {
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.slide-content {
  width: 100%;
  height: 100%;
  background: blue;
  border-radius: 2rem;
}

@keyframes slide {
  0% {
    scale: 0.8;
  }
  50% {
    scale: 1;
  }
  100% {
    scale: 0.8;
  }
}