I'm trying to center images in css grid and also make the image cover the whole container. Here is the html and css code,
.object-wrapper {
display: grid;
grid-template-columns: repeat(45, 1fr);
grid-template-rows: repeat(60, 1fr);
grid-gap: 0px;
max-width: 550px;
max-height: 720px;
justify-content: center;
}
.object-wrapper div {
background: transparent;
padding: 5px;
max-height: 5px;
max-width: 5px;
text-align: center;
border: 0.001px solid whitesmoke;
font-size: 5px;
}
img {
max-height: 100%;
text-align: center;
margin-left: auto;
margin-right: auto;
display: block;
object-fit: cover;
}
<div id="object">
<div class="object-wrapper">
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div><img src="troll.jpg"></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
When it displays the images appear in the middle of the intersections of the grid.
Any help would be appreciated, thanks!