My goal is to add a background to both the image and the div itself, similar to what I've seen on Amazon. However, I'm struggling to achieve this effect where the white background of the image doesn't show when applied onto the div:
Image with white background:
https://i.sstatic.net/QbX9R.png
Image being rendered onto the div:
https://i.sstatic.net/TAmLv.png
This is what I have attempted so far:
.grid-wrapper {
display: grid;
grid-template-columns: 1fr 2fr;
background: #fff;
box-shadow: rgba(0, 0, 0, 0.02) 0px 1px 3px 0px, rgba(27, 31, 35, 0.15) 0px 0px 0px 1px;
border-radius: 4px;
}
.image-block {
background: red;
margin: auto;
}
.image-block img {
width: 100%
height: 100%;
}
.information {
padding: 10px;
}
.information p {
font-size: 0.875rem;
line-height: 1.5;
}
<div class="grid-wrapper">
<div class="image-block">
<img src="https://m.media-amazon.com/images/I/61xgpXecLML._AC_UY218_.jpg">
</div>
<div class="information">
<p>Logitech M510 Wireless Computer Mouse for PC with USB Unifying Receiver - Graphite</p>
<p>Price: $100</p>
</div>
</div>
The issue I'm facing is that the background: red;
is partially visible under the image.