img {
object-fit: cover;
width: 100px;
height:100px;
}
img {
display: block;
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
}
img {
display: block;
max-width:230px;
max-height:95px;
width: auto;
height: auto;
}
Don't set height AND width. Use one or the other and the correct aspect ratio will be maintained.
.image-full {
background: url(...some image...) no-repeat;
background-size: cover;
background-position: center center;
}
/* Simply add width without height,
aspect ratio will be maintained
and height will be calculated accordingly*/
img {
width: 100px;
}
Code Example |
---|
Css :: flexbox css properties |
Css :: woolentor product archive not centered |
Css :: background image causes webpage scrolling slow |
Css :: phone css |
Css :: affect top div opacity without affecting childrne |
Css :: operador css contain attr |
Css :: animation not hover out |
Css :: how to change a checkbox to be selected |
Css :: css tricks macos spaces in dock |
Css :: make table cell less wide css |
Css :: css font-family |
Css :: border bottom css |
Css :: import import bootstrap-social as css file; |
Css :: font-style |
Css :: css margin |
Css :: css folded corner |
Css :: adding diffent style in firefox css |
Css :: flexbox in css |
Css :: min width css |
Css :: css active button |
Css :: react datepicker css not working |
Css :: css light mode |
Css :: linking in css |
Css :: matrix in css |
Css :: scroll css |
Css :: css nearest neighbor |
Css :: tabs css only |
Css :: pink hex code |
Css :: ffmpeg add text with positions relative to video & text dimensions |
Css :: css clip path alternative |