【问题标题】:How to change Z-index for the price in Woocommerce?如何更改 Woocommerce 中价格的 Z-index?
【发布时间】:2021-11-23 15:17:38
【问题描述】:

我正在使用带有 Astra 主题和 Elementor 的 Woocmmerce。我已经习惯在这里和那里使用 CSS 来避免使用昂贵的插件来调整我的 Woocommerce 商店。我决定在缩略图上使用价格,并为缩略图设置了负底部填充以将价格和“添加到购物车”拖得更高。我可以看到该按钮的 z-index 肯定高于缩略图。问题是价格完全被缩略图隐藏了,即使在 Elementor 中它在缩略图之上。我尝试在 CSS 中使用 z-index 但无济于事。我错过了什么吗? 这是我的 CSS 代码示例。

.woocommerce div.product p.price, .woocommerce div.product span.price{
    background-color: #fff;
    z-index: 99;
}

【问题讨论】:

    标签: css wordpress woocommerce elementor


    【解决方案1】:

    也许使用!important,如果z-index 已经设置在.woocommerce 的其他地方:

    .woocommerce div.product p.price, .woocommerce div.product span.price {
        background-color: #fff;
        z-index: 99 !important;
    }
    

    【讨论】:

    • 我也试过了!important。它没有工作
    【解决方案2】:

    对于具有 z-index 的项目,您必须设置除静态之外的位置属性。 https://developer.mozilla.org/en-US/docs/Web/CSS/z-index

    .woocommerce div.product p.price, .woocommerce div.product span.price{
        background-color: #fff;
        z-index: 99;
        position: relative;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 2020-12-15
      • 2021-11-17
      • 1970-01-01
      • 1970-01-01
      • 2014-02-02
      相关资源
      最近更新 更多