【问题标题】:WooCommerce - Hide product images if noneWooCommerce - 如果没有则隐藏产品图片
【发布时间】:2015-08-11 09:39:44
【问题描述】:

我正在使用 WooCommerce 在 Bootstrap 中开发一个主题。我正在尝试隐藏产品图像/图库所在的 col-md-1(如果没有),并将我的产品图像列从 col-md-5 变为 col-md-6

页面设计由 3 列组成:

  1. col-md-5 - 产品图片
  2. col-md-1 - 产品图片/图库
  3. col-md-6 - 产品信息

Here you can see where the product has more images in the col-md-1

Here you see it without product images

【问题讨论】:

  • 一开始你是如何展示画廊的?很难告诉你如何在没有看到你的代码的情况下修改你的代码。

标签: php wordpress twitter-bootstrap woocommerce


【解决方案1】:

这是一个可以帮助你的代码。

jQuery( document ).ready(function(){
if(jQuery('.col-md-1').children().length===0){
jQuery('.col-md-1').css('display','none');
jQuery('.col-md-5').toggleClass('col-md-6');
jQuery('.col-md-5').removeClass('col-md-5');
}
});

先在浏览器中加载页面,然后将以下代码粘贴到控制台查看效果。

如果此代码是您想要的,则添加相同的代码以有条件地仅将其加载到单个产品页面上。

【讨论】:

  • 为什么前端需要在后端做一些事情?加上问题中没有js标签
  • 因为它在问题中标记了 twitter-bootstrap,所以在 jQuery 中给出了解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-10
相关资源
最近更新 更多