img src的图片实现background-size: cover 效果

object-fit CSS属性指定如何将替换元素的内容适配到由其使用的高度和宽度建立的框。

img {
    object-fit: cover;
    object-position:left center;
}
/* Keyword values */
object-fit: fill;
object-fit: contain;
object-fit: cover;
object-fit: none;
object-fit: scale-down;

/* Global values */
object-fit: inherit;
object-fit: initial;
object-fit: unset;
fill 或 none

contain 或 scale-down

cover

can i use it ??

object-fit / object-position 兼容性

你可能感兴趣的:(img src的图片实现background-size: cover 效果)