img {
object-fit: cover;
width: 100px;
height:100px;
}
img {
display: block;
max-width: 100%;
max-height: 100%;
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;
}
Code Example |
---|
Css :: css smooth text shadow |
Css :: how to make a glow effect in html |
Css :: change scroll style angular |
Css :: remove button default border css |
Css :: how to center items in css |
Css :: css grid wrap columns |
Css :: center in grid |
Css :: flex center |
Css :: css remove list indent |
Css :: install cors |
Css :: page icon css |
Css :: vertical text |
Css :: how to remove link color from <a |
Css :: hex code for khaki |
Css :: how to make background more darker with css |
Css :: css margin bottom |
Css :: css disable mouse events |
Css :: how to stop a page from scrolling horizontally |
Css :: elementor is swiping |
Css :: gradient over image css |
Css :: scss light color |
Css :: css background full screen |
Css :: how to add space inbetween lines in html |
Css :: color code for dark green |
Css :: hr tag customize using css |
Css :: css system default font |
Css :: font awesome eyes |
Css :: css parallelogram |
Css :: not hover css |
Css :: css orange color |