I want my 3 images to be the same size, but width/height styles aren’t helping, because when I set the same size for all images, all 3 images keep their aspect ratio and they look horrible.
.social {
display: flex;
}
.items_soc {
height: auto;
width: 50px;
object-fit: cover;
/* filter: brightness(0%) invert(100%); */
}
<div class="social">
<img class="items_soc" src="https://via.placeholder.com/100x150" />
<img class="items_soc" src="https://via.placeholder.com/150x150/aaa" />
<img class="items_soc" src="https://via.placeholder.com/150x100" />
</div>
2
Answers
Object fit works the best when you have a constant aspect ratio.
Change the code to
I see what is your problem and if you want them be the same height and width it will be dependent if you want it vertical or horizonal order for the method I will stating.
For this you must enclose each image within the
<div>
element. Once you have done that you can use CSS to declare the specifics for its height and width. You can use the style attribute within the div opening tag.style = "width : 100px; height: 100px;"
. It follows the same rules.Then you can insert your images with its sources. Their aspect ratio should stay the same and fit within the div.
This is more for list and rosters but you can also just try to have a height value and have the width as auto instead.
Same result, different use case.