following various online tutorials, I'm trying to make an image gallery which just simply displays square cropped images. It appears to work on the second and third row, but for what ever reason not on the first row? Does anyone know what I might be doing wrong?
.article {
border: 1px solid red;
max-width: 1000px;
}
.gallery {
border: 1px solid blue;
display: flex;
flex-wrap: wrap;
}
.gallery-item {
border: 1px solid red;
flex-basis: 49%;
}
.gallery-item:before {
content: "";
float: left;
padding-top: 100%;
}
.gallery-img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div class='article'>
<h1>
title titile title
</h1>
<div class='gallery'>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/500' />
</div>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/500x750' />
</div>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/750x500' />
</div>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/750x500' />
</div>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/300x300' />
</div>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/750x750' />
</div>
<div class='gallery-item'>
<img class='gallery-img' src='https://via.placeholder.com/750x750' />
</div>
</div>
</div>
Codepen: https://codepen.io/pandalism/pen/XWdyJbz
Any direction at all would be great thanks!