keep aspect ratio of image css
img {
display: block;
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
}
keep aspect ratio of image css
img {
display: block;
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
}
css keep image ratio
img {
object-fit: cover;
width: 100px;
height:100px;
}
preserve aspect ratio image css
/* Simply add width without height,
aspect ratio will be maintained
and height will be calculated accordingly*/
img {
width: 100px;
}
css keep aspect ratio image
.image-full {
background: url(...some image...) no-repeat;
background-size: cover;
background-position: center center;
}
html image keep aspect ratio
Don't set height AND width. Use one or the other and the correct aspect ratio will be maintained.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us