gpt4 book ai didi

html - 如何拉伸(stretch)图像以填充图形标签

转载 作者:行者123 更新时间:2023-11-28 19:13:18 25 4
gpt4 key购买 nike

我正在构建一个图像网格,并且我有一个图形标签列表,每个标签中都有一个图像。图像大小不同,所以如果我设置

max-width: 100%;
height: auto;

他们看起来不一样。

如何使所有图像都适合图形大小相同?我可以拉伸(stretch)不完全适合的图像。

谢谢

最佳答案

在具有containcover 属性的img 标签上使用objectfit

figure img {
object-fit: contain;//contain the image you can use cover to fill the div with image
width: 200px;//desire width
height: 200px;//desire height
}

关于html - 如何拉伸(stretch)图像以填充图形标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58913883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com