OP提到他们只能访问CSS文件。
在这种情况下,您需要稍微更改一下CSS选择器,但仍然可行。下面的示例将类应用于要更改的元素的父元素。
.change p {
color: pink !important;
}
<div class="change">
<p style="color: blue;">
This is some text.
</p>
</div>
.change div p:nth-child(2) {
color: pink !important;
}
<div class="change">
<p style="color: blue;">
This is some text.
</p>
<div>
<p style="color: green;">
This is some text.
</p>
<p style="color: orange;">
This is some text. (only change me)
</p>
</div>
</div>
我猜你没有直接将 CSS 类应用于要更改的元素,因为我没有看到示例<span>中应用.product-description
。
看看下面的两个示例。
我认为你正在尝试这个,将类应用于要更改的外部元素。<p>
将继承.change
的颜色,如果<p>
没有具有更高特异性的东西,例如内联 CSS 或另一个 CSS 类。
在这里,我们直接将类应用于要更改的元素,这样!important
的特异性可以覆盖内联 CSS 的特异性。
.change {
color: pink !important;
}
<!-- #1 -->
<div class="change">
<p style="color: green;">
This is some text.
</p>
</div>
<!-- #2 -->
<div>
<p class="change" style="color: green;">
This is some text.
</p>
</div>
.product-description *
将会将样式应用到 .product-description
的每一个子元素。 - hungerstar
!important
的。看错了。 - Hunter Turnerfont-family: "Wide Latin" !important;
,看看是否有任何效果。 - Robert.product-description
与你上面显示的span
之间的关系。你可能需要调整你的选择器,使其类似于.product-description span {}
或类似的内容。 - Robert