JSFiddle - React, Tailwind, and code Playground

by Jordan Sayner

HTML

<div class="container">
  <img src="your-image.jpg" alt="Background">
  <div class="content">
    <p>Your content here</p>
    <p>Your content here</p>
    <p>Your content here</p>
  </div>
</div>

CSS

.container {
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 1fr;
  width: 100%; /* Adjust based on content width */
}

.container img,
.container .content {
  grid-row: 1 / 2;
  grid-column: 1 / 2;
}

.container img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Ensures the image covers the available space */
}

.container .content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5); /* Optional overlay */
  color: white;
}