---
title: "Gallery"
description: "Slides of different widths, with a sliver of the previous and next slide on either side."
canonical_url: "https://www.blossom-carousel.com/docs/examples/advanced/gallery"
---

> Index of every page on this site: [llms.txt](https://www.blossom-carousel.com/llms.txt)

<supports-view-timeline-support>
<caution>

View-timeline is not yet supported in this browser. Check browser compatibility at [caniuse.com](https://caniuse.com/?search=view-timeline)

</caution>
</supports-view-timeline-support>

<example-gallery>



</example-gallery>

<tabs sync="example-code-style">
<tabs-item label="CSS">
<code-group>

```css [.css]
.carousel {
  /* How much of the previous and next card stays visible. */
  --peek: 40px;
  /* The smallest space between two cards. */
  --gap: 12px;
  --inset: calc(var(--peek) + var(--gap));

  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  padding-inline: var(--inset);
  scroll-snap-type: x mandatory;
}

.slide {
  display: flex;
  justify-content: center;
  scroll-snap-align: center;

  container-type: inline-size;
  /* The inset makes the timeline run from one slide before to one slide after. */
  view-timeline: --slide inline var(--inset);
}

.card {
  height: 16rem;

  animation: gallery linear both;
  animation-timeline: --slide;
  animation-range: cover;
}

/* 50cqi - 50% is the empty space beside the card, so narrow cards move further. */
@keyframes gallery {
  from {
    transform: translateX(calc(50% - 50cqi + var(--gap)));
  }
  to {
    transform: translateX(calc(50cqi - 50% - var(--gap)));
  }
}
```

```html [.html]
<BlossomCarousel class="carousel">
  <div class="slide">
    <div class="card" style="width: 60%"></div>
  </div>
  <div class="slide">
    <div class="card" style="width: 90%"></div>
  </div>
  <div class="slide">
    <div class="card" style="width: 45%"></div>
  </div>
  ...
</BlossomCarousel>
```

</code-group>
</tabs-item>

<tabs-item label="Tailwind">
<code-group>

```css [.css]
.carousel {
  /* How much of the previous and next card stays visible. */
  --peek: 40px;
  /* The smallest space between two cards. */
  --gap: 12px;
  --inset: calc(var(--peek) + var(--gap));
}

.slide {
  container-type: inline-size;
  /* The inset makes the timeline run from one slide before to one slide after. */
  view-timeline: --slide inline var(--inset);
}

.card {
  animation: gallery linear both;
  animation-timeline: --slide;
  animation-range: cover;
}

/* 50cqi - 50% is the empty space beside the card, so narrow cards move further. */
@keyframes gallery {
  from {
    transform: translateX(calc(50% - 50cqi + var(--gap)));
  }
  to {
    transform: translateX(calc(50cqi - 50% - var(--gap)));
  }
}
```

```html [.html]
<BlossomCarousel
  class="carousel grid! snap-x snap-mandatory auto-cols-[100%] grid-flow-col px-(--inset)!"
>
  <div class="slide flex! snap-center justify-center">
    <div class="card h-64" style="width: 60%"></div>
  </div>
  <div class="slide flex! snap-center justify-center">
    <div class="card h-64" style="width: 90%"></div>
  </div>
  <div class="slide flex! snap-center justify-center">
    <div class="card h-64" style="width: 45%"></div>
  </div>
  ...
</BlossomCarousel>
```

</code-group>
</tabs-item>
</tabs>

## Sitemap

See the full [sitemap](https://www.blossom-carousel.com/sitemap.md) for all pages.
