<div class="container">
  <div class="image-container">
    <img src="https://source.unsplash.com/tMHAmxLyzvA" alt="Boston city skyline" id="img1">
    <div class="overlay">
      <p class="caption">Hover Text</p>
      <p>Kinsta is a Cloud Platform designed to help companies and dev teams ship and manage their web projects faster and more efficiently.</p>
    </div>
  </div>
  <div class="image-container">
    <img src="https://source.unsplash.com/tMHAmxLyzvA" alt="Boston city skyline" id="img2">
    <div class="overlay">
      <p class="caption">Hover Text</p>
      <p>Kinsta is a Cloud Platform designed to help companies and dev teams ship and manage their web projects faster and more efficiently.</p>
    </div>
  </div>
  <div class="image-container">
    <img src="https://source.unsplash.com/tMHAmxLyzvA" alt="Boston city skyline" id="img3">
    <div class="overlay">
      <p class="caption">Hover Text</p>
      <p>Kinsta is a Cloud Platform designed to help companies and dev teams ship and manage their web projects faster and more efficiently.</p>
    </div>
  </div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap");

body {
  background-color: #ddd;
  font-family: "Poppins", sans-serif;
}

.container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.image-container {
  position: relative;
  display: inline-block;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #fff;
}

.image-container:hover .overlay {
  opacity: 1;
}

.overlay p {
  padding:10px;
  font-weight: bold;
}

.overlay .caption{
  font-size: 20px;
}

.container div {
  display: flex;
  align-items: center;
  flex-direction: column;
}

img {
  height: 300px;
  width: 300px;
  object-fit: cover;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.