# Caption Overlay Card

> An image card with a dark gradient overlay that keeps the caption readable.

- Category: [CSS Cards](https://copy-css.com/category/cards)
- Tags: image, overlay, caption, gradient, hover
- Live preview: https://copy-css.com/snippets/caption-overlay-card
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<a class="overlay-card" href="#">
  <div class="overlay-media"></div>
  <div class="overlay-text">
    <small>Travel</small>
    <strong>Morning in the hills</strong>
  </div>
</a>
```

## CSS

```css
.overlay-card {
  position: relative;
  display: block;
  overflow: hidden;
  width: 220px;
  height: 160px;
  border-radius: 16px;
  color: #fff;
  text-decoration: none;
  font-family: system-ui, sans-serif;
}

/* Swap the background for your own image */
.overlay-media {
  position: absolute;
  inset: 0;
  background: #94a3b8 center / cover;
  transition: transform 0.4s ease;
}

.overlay-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent 60%);
}

.overlay-card:hover .overlay-media {
  transform: scale(1.06);
}

.overlay-text {
  position: absolute;
  z-index: 1;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: grid;
  gap: 2px;
}

.overlay-text small {
  opacity: 0.8;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-text strong {
  font-size: 16px;
}
```

## Notes

- This CSS Caption Overlay Card is 51 lines of pure CSS (0.9 KB) with no JavaScript and no dependencies. It uses transitions, transforms, linear gradients and CSS Grid.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
