Like an option, you can use grid approach to make text content to be on front of image with overlaying.
In this case, your text and image will be relevant to each other, see Code snippet for details:
Also, to manage overlay size, you can use CSS variables, like this one --overlay-size: 10%;.
.wrapper-grid {
display: grid;
grid-template-areas: 'content'; /* creating grid areas */
align-items: center;
--overlay-size: 10%; /* overlay size */
}
.wrapper-grid .text,
.wrapper-grid .image {
grid-area: content; /* use same cell for text and image */
}
.wrapper-grid .text {
z-index: 1; /* place text in front of image */
max-width: calc(50% + var(--overlay-size, 0));
font-size: 1.5rem;
font-weight: bold;
line-height: 1.4;
}
.wrapper-grid .image {
width: calc(50% + var(--overlay-size, 0));
justify-self: flex-end; /* aligning image to the right */
}
<div class="wrapper-grid">
<p class="text">Maecenas egestas arcu quis ligula mattis placerat. Suspendisse pulvinar, augue ac venenatis condimentum.</p>
<img class="image" src="https://picsum.photos/seed/picsum/600/400" />
</div>