如何将不同尺寸的图像适合“框”在WooCommerce中,单产品页面图像滑块

发布于 2025-02-13 14:18:16 字数 1019 浏览 1 评论 0原文

我偶然发现了WooCommerce单产品页面图像尺寸的一个问题。 产品图像的尺寸不是相同的,这就是为什么其中一些作物的原因。

我添加了此CSS试图解决此问题:

.woocommerce.single-product #content div.product div.images, .woocommerce.single-product div.product div.images, .woocommerce-page.single-product #content div.product div.images, .woocommerce-page.single-product div.product div.images {
    min-height: 500px;
    min-width: 650px;
    max-height: 500px;
    max-width: 650px;
    }

 div.woocommerce-product-gallery__image.flex-active-slide{
height: 400px;
object-fit: cover;
}

它将照片滑块的位置和大小放置在我想要的位置,但是当我浏览照片时,一些照片会裁剪。我需要所有的照片才能适应高度(400px)。应自动设置宽度,以使图像在400px高度下完全可见。也许有人知道该怎么做?

使用WordPress + Elementor + ShopTimizer主题

链接到单个产品页面: https://benideco.com/product/lawa-design-modernus-laikrodis-delta-azuolo-spalvos-su-juodomis-rodyklemis/

非常感谢!

I stumbled upon one problem with WooCommerce single product page image sizes.
Product images are not the same size, that's why some of them crops.

I added this css trying to fix this:

.woocommerce.single-product #content div.product div.images, .woocommerce.single-product div.product div.images, .woocommerce-page.single-product #content div.product div.images, .woocommerce-page.single-product div.product div.images {
    min-height: 500px;
    min-width: 650px;
    max-height: 500px;
    max-width: 650px;
    }

 div.woocommerce-product-gallery__image.flex-active-slide{
height: 400px;
object-fit: cover;
}

It puts the location and size of the photos slider and the active photo where I want them to be, but when I go through the photos, some of the photos get cropped. I need all the photos to fit to height (400px). The width should be automatically set so that the image is fully visible at 400px height. Maybe someone knows how to do it?

Using WordPress + Elementor + Shoptimizer theme

Link to single product page: https://bonideco.com/product/lawa-design-modernus-laikrodis-delta-azuolo-spalvos-su-juodomis-rodyklemis/

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落日海湾 2025-02-20 14:18:16

经过数小时的研究,我终于找到了满足我需求的代码。

.woocommerce div.product div.images a img {
height: 400px;
object-fit: contain;
object-position: top;
}

After many hours of research I finally found the code that meet my needs.

.woocommerce div.product div.images a img {
height: 400px;
object-fit: contain;
object-position: top;
}
执手闯天涯 2025-02-20 14:18:16

输入自定义CSS:

.woocommerce div.images a img {
height: 400px! important;
object-fit: contain ;
object-position: top;
}

Enter in custom CSS:

.woocommerce div.images a img {
height: 400px! important;
object-fit: contain ;
object-position: top;
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文