CSS:内部元素的格式化问题



我有一个问题,这个css在网上商店。这是一个云商店,所以我不能改变文件,只有CSS。

是否有办法改变4.799文本为红色?必须有某种函数来改变除了"productoldprice"子元素之外的所有内容。任何想法?谢谢。

<span class="current-price-container" title="Product-Title"> 
<span class="productOldPrice">UVP 4.900,00 EUR</span>
<br>
Nur 4.799,00 EUR</span>
编辑:澄清问题。我有其他当前价格容器,如果它们不包含productOldPrice,我不想重新格式化。
.current-price-container{
color:red;
}
.productOldPrice{
color:grey;
}

既然你想改变父span的文本颜色,那么你可以改变父span的文本颜色为红色,然后给子span默认的颜色

.current-price-container { color: red }
.productOldPrice { color: #000 }
<span class="current-price-container" title="Product-Title"> 
<span class="productOldPrice">UVP 4.900,00 EUR</span>
<br>
Nur 4.799,00 EUR</span>

是的,你可以做到:)

.current-price-container  {color:red}
.productOldPrice{color:black}
<span class="current-price-container" title="Product-Title"> 
<span class="productOldPrice">UVP 4.900,00 EUR</span>
<br>
Nur 4.799,00 EUR</span>

您可以使用:not伪选择器,这可能适合您的逻辑"…除了(x)"

.current-price-container .productOldPrice {
color: black;
}
.current-price-container:not(.productOldPrice) {
color: red;
}

最新更新