<div class="img-box">
<img src="" alt="" />
</div>
// css样式保持图片宽高始终一致设置
.img-box {
position: relative;
width: 100%;
height: 0;
padding-bottom: 100%;
}
.img-box img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}