Fade Caption

A caption text treatment fades into view over the bottom of the image on hover/focus.

Fade Caption demo

Hover or focus the image to see the effect.

HTML

<div class="hover-effect fade-caption">
  <img src="image.jpg" alt="description">
</div>

CSS

.hover-effect.fade-caption{
  position: relative;
}
.hover-effect.fade-caption::after{
  content: "Hover caption";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.hover-effect.fade-caption:hover::after,
.hover-effect.fade-caption:focus-visible::after{
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .hover-effect.fade-caption::after{
    transition: none;
  }
  .hover-effect.fade-caption:hover::after,
  .hover-effect.fade-caption:focus-visible::after{
    opacity: 1;
  }
}

Edit the content string in ::after to set your own caption text. Select the code and copy with Ctrl+C or ⌘C.