# Grid Stack Overlay

> Layer badges and captions over an image by placing everything in one grid cell. No absolute positioning.

- Category: [CSS Layouts](https://copy-css.com/category/layouts)
- Tags: grid-area, overlay, stack, layer, no absolute, image
- Live preview: https://copy-css.com/snippets/grid-stack
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<figure class="stack">
  <div class="stack-media"></div>
  <span class="stack-badge">New</span>
  <figcaption>Golden hour</figcaption>
</figure>
```

## CSS

```css
.stack {
  display: grid;
  margin: 0;
}

/* Every child shares the same cell */
.stack > * {
  grid-area: 1 / 1;
}

/* Use an <img> here in real projects */
.stack-media {
  min-height: 140px;
  border-radius: 14px;
  background: #d4d4d8;
  object-fit: cover;
}

.stack-badge {
  align-self: start;
  justify-self: end;
  margin: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #18181b;
  color: #fff;
  font: 700 11px system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stack figcaption {
  align-self: end;
  justify-self: start;
  margin: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #18181b;
  font: 600 13px system-ui, sans-serif;
}
```

## Notes

- This CSS Grid Stack Overlay is 43 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses backdrop filters and CSS Grid.
- backdrop filters: Includes the -webkit- prefix for older Safari.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
