I have set of pictures in different sizes displayed in css-grid.
How to display all the pictures to be display in 1.6 aspect radio?
In my code I need to have three columns in row. grid-template-columns:1fr 1fr 1fr;
.
But the pictures are changing the item size and not in right aspect radio and I have a lot of white space in the picture.
What is missing in my code?
Here is the code:
.wrap {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.wrap .item {
border: 1px solid red;
overflow: hidden;
}
.wrap .item img {
height: auto;
width: auto;
max-width: 270px;
max-height: 180px;
}
<div class="wrap">
<div class="item"><img src="https://picsum.photos/id/562/500/300"></div>
<div class="item"><img src="https://picsum.photos/id/588/500/500"></div>
<div class="item"><img src="https://picsum.photos/id/563/400/350"></div>
<div class="item"><img src="https://picsum.photos/id/564/500/400"></div>
<div class="item"><img src="https://picsum.photos/id/565/300/300"></div>
<div class="item"><img src="https://picsum.photos/id/566/270/180"></div>
</div>