Trying to overlay text on an image using the code snippet below;
https://i.sstatic.net/7jkEC.png
<div class="wrapper">
<img src="https://cdn0.vox- cdn.com/thumbor/qLH7593e3D2SSSIdkwgBWdYhjjk=/289x0:802x684/400x533/filters:forma t(webp)/cdn0.vox-cdn.com/uploads/chorus_image/image/47859707/6621139883_e6be6a217a_b__1_.0.0.jpg" alt="" />
<div class="overlay">
<h2>Restaurant Stowaway Devours $800 of Roast Goose and Wine</h2>
</div>
</div>
CSS
body {
text-align: center;
}
.wrapper {
display: inline-block;
margin-top: 25px;
position: relative;
}
.wrapper img {
display: block;
max-width:100%;
}
.wrapper .overlay {
position: absolute;
top:0;
left:0;
width:100%;
height:100%;
background-color: rgba(0,0,0,0.25);
color:white;
}
However, the result appears different from what was expected as shown in this image: https://i.sstatic.net/zAi5J.png
I could use some assistance in identifying what I have overlooked, as I aim to achieve the desired output similar to the initial image displayed above.