我正在尝试定位运行WooCommerce的WordPress安装上提供的产品的特定属性。具体来说,我正在尝试定位产品价格和产品小计。
我找到了我认为是产品ID类“ postid-1539”的东西,并且找到了需要调整“ .product-price”和“ .product-subtotal”的属性。但是我不能专门调整特定产品的属性以使其显示不同。
我应该用钩子和过滤器解决这个问题吗?我以为CSS是最简单的方法。
我的正确且非工作代码如下所示
.postid-1539 .product-price {display; none:}
帮忙。 :P
最佳答案
考虑到targeting
元素,您的意思是selecting
更改其样式的元素。我可以给你这个解决方案:
.shop_table .product-price{ /* Font color of price is made green */
color:Green;
}
.shop_table .quantity input.input-text{ /* Background color of quantity text box is made green */
background:Green;
color:#FFFFFF;
}
请记住,您可以在带有
space
的父元素内选择子元素,例如:[parentTag/#parentId/.parentClass][SPACE][childrenTag/.childrenClass]
,在您的示例中为.shop_table .product-price
。其中.shop_table
是父元素的类,而.product-price
是子元素。因此,我们根据他们的班级选择了他们,中间使用space
。但是要选择类
input
的.input-text
元素,您必须将这两个类连接起来:input.input-text
这将仅更改input
类的.input-text
元素,而不会影响具有input
类的其他元素。其他课程。为了更好地了解CSS选择器,请访问this链接。
关于css - 在WooCommerce/WordPress中使用CSS定位产品的属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36416576/