css set image aspect ratio code example
Example 1: css keep image ratio
img {
object-fit: cover;
width: 100px;
height:100px;
}
Example 2: preserve aspect ratio image css
/* Simply add width without height,
aspect ratio will be maintained
and height will be calculated accordingly*/
img {
width: 100px;
}