P粉1916105802023-08-17 00:28:09
要解決這個問題,您可以使用object-fit
CSS屬性。 object-fit屬性指定了影像應如何調整大小以適應其容器。 cover值將調整影像大小以填充整個容器,同時保持其縱橫比。
<span class="bg-dark d-flex justify-content-center align-items-center"> <img :src="slotProps.item.itemImageSrc" :alt="slotProps.item.alt" style="object-fit: cover; max-width: 100%; max-height: 100%" /> </span>