I am trying to do a grid example and overlay multiple images.
But the problem is that in Firefox the images take up 100% height when I set it, in Chrome it's 0, as a hack I have to set one image to auto.
.image-1 {
height: auto; /* <-- this part on Chrome*/
grid-column: 4 / span 4;
grid-row: 1 / span 4;
}
Could someone help how to do this without any hacks?
Codepen: https://codepen.io/adtm/pen/GXrLrG
body {
width: 1024px;
margin: 40px auto;
}
section {
display: grid;
grid-auto-rows: 1fr;
grid-template-columns: repeat(10, 1fr);
}
img {
border: 1px solid red;
width: 100%;
height: 100%;
object-fit: cover;
}
.image-1 {
height: auto; /* <-- this part on Chrome*/
grid-column: 4 / span 4;
grid-row: 1 / span 4;
}
.image-2 {
grid-column: 1 / span 4;
grid-row: 3 / span 4;
}
.image-3 {
grid-column: 4 / span 4;
grid-row: 5 / span 3;
}
.image-4 {
grid-column: 6 / span 4;
grid-row: 3 / span 4;
}
<section>
<img src="https://via.placeholder.com/200x150" alt="1" class="image-1">
<img src="https://via.placeholder.com/350x350" alt="2" class="image-2">
<img src="https://via.placeholder.com/150x150" alt="3" class="image-3">
<img src="https://via.placeholder.com/350x250" alt="4" class="image-4">
</section>