I'm trying to cover a flex-box container with an image but the CSS property object-fit
doesn't seem to be working and is not fitting my image which is 1536 x 1536 which is much bigger than what the dimensions are for the container. This is what it looks like:
And this is what the image looks like:
How can I fit this image into that flex box container?
.flex-container {
display: flex;
flex-wrap: wrap;
border-radius: 16px;
background-color: linear-gradient(90deg, rgba(244, 247, 252, 0.5) 0%, rgba(244, 247, 252, 0.5) 100%);
justify-content: center;
}
.flex-container>div {
background-color: white;
width: 20vh;
margin: 15px;
text-align: center;
line-height: 20vh;
font-size: 30px;
object-fit: contain;
}
.sdg1 {
background: url("https://via.placeholder.com/1536.jpg");
}
<div className="flex-container">
<div className="sdg1"></div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
<div>SDG</div>
</div>