#起源在于object-fit:contain一直没有生效#
很好解决,原因是也要给图片宽高也设置为100%。
/*
@demo-image__preview:放图片的外层div;
@el-image:图片;
*/
.demo-image__preview {
width: 120px;
height: 100px;
background-color: #f2f2f2;
display: flex;
align-items: center;
justify-content: center;
margin-bottom:10px;
.el-image {
width: 100%;
height: 100%;
object-fit: contain;
}
}