xxxxxxxxxx
img {
display: block;
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
}
xxxxxxxxxx
/* Keyword values */
aspect-ratio: auto; /* default */
/* Ratio values */
aspect-ratio: 1 / 1; /* width and height are equal proportion */
aspect-ratio: 2 / 1; /* width is twice the height*/
aspect-ratio: 1 / 2; /* width is half the height */
aspect-ratio: 16 / 9 /* typical video aspect ratio */
aspect-ratio: auto 4 / 3; /* width:height, unless it's a replaced element */
aspect-ratio: 0.5; /* float value */
/* Global values */
aspect-ratio: inherit;
aspect-ratio: initial;
aspect-ratio: unset;
xxxxxxxxxx
img {
display: block;
max-width:230px;
max-height:95px;
width: auto;
height: auto;
}
xxxxxxxxxx
Don't set height AND width. Use one or the other and the correct aspect ratio will be maintained.
xxxxxxxxxx
.image-full {
background: url(some image ) no-repeat;
background-size: cover;
background-position: center center;
}
xxxxxxxxxx
/* Simply add width without height,
aspect ratio will be maintained
and height will be calculated accordingly*/
img {
width: 100px;
}