.box img { max-width: none; object-fit: cover; /* 这一行是重点,下面的宽高都要设置为100%,加上这个属性就不会变形了 */ width: 100%; height: 100%; }