xxxxxxxxxx
/* With img element */
.my-image {
width: 100px;
height: 100px;
object-fit: contain;
}
/* with background image */
.my-image {
width: 500px;
height: 400px;
background-image: url('myurl.jpg');
background-size: cover;
}
xxxxxxxxxx
#myDiv
{
height: 104px;
width: 140px;
}
#myDiv img
{
max-width: 100%;
max-height: 100%;
margin: auto;
display: block;
}
xxxxxxxxxx
.whatever {
width: 500px;
height: 400px;
background-image: url('myurl.jpg');
background-size: cover;
}
xxxxxxxxxx
img {
max-width: 50vw;
aspect-ratio: 1/1;
border: 2px solid black;
object-fit: cover;
object-position: 50% 10%;
}