Reputation: 33
I got problem to handle image ratio. It become like this image:
But when I adjust image size it become like this:
How to handle it?
.itemBox {
height: 195px;
margin: 15px;
border-radius: 4px;
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);
background-color: #e4b972;
}
.item_img {
width: 120px;
height: 195px;
}
<div class="itemBox">
<div style="float:left;">
<img class="item_img" src="https://thumbs.dreamstime.com/z/no-image-available-icon-flat-vector-no-image-available-icon-flat-vector-illustration-132482953.jpg" />
</div>
</div>
Upvotes: 0
Views: 527
Reputation: 1142
set the size and width in the div and contain your image in the div
.itemBox {
height: 195px;
margin: 15px;
border-radius: 4px;
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2);
background-color: #e4b972;
}
.div-for-img {
width: 120px;
height: 195px;
float: left;
}
.item_img {
height: 100%;
object-fit: contain;
}
<div class="itemBox">
<div class="div-for-img">
<img class="item_img" src="https://thumbs.dreamstime.com/z/no-image-available-icon-flat-vector-no-image-available-icon-flat-vector-illustration-132482953.jpg" />
</div>
</div>
Upvotes: 2