如何仅设置 p 标签内的文本样式
How to only style the text inside a p tag
<div>
<p style="font-size=40px;">
<b>Hello there, welcome</b>
<br/>
To this website
</p>
<p>Some other text</p>
如何只抓取第一个 p 标签 ("To This Website") 内的文本?
我不能给它一个 class 或 ID,因为它是在 wordpress 中用 visual composer 完成的,我也不能在 wordpress 中设置它的样式,但我只需要设置那部分的样式。
也许是这样的?
http://codepen.io/anon/pen/YGpvxE
下面的代码片段示例
p:first-child {
color: red !important; /** Use important only in very rare situations **/
}
p b {
color: initial;
}
<div>
<p>
<b>Hello there, welcome</b>
<br/>
To this website
</p>
<p>Some other text</p>
</div>
编辑:
要覆盖内联样式,您可以在 css.
中使用 !important
<div>
<p style="font-size=40px;">
<b>Hello there, welcome</b>
<br/>
To this website
</p>
<p>Some other text</p>
如何只抓取第一个 p 标签 ("To This Website") 内的文本? 我不能给它一个 class 或 ID,因为它是在 wordpress 中用 visual composer 完成的,我也不能在 wordpress 中设置它的样式,但我只需要设置那部分的样式。
也许是这样的?
http://codepen.io/anon/pen/YGpvxE
下面的代码片段示例
p:first-child {
color: red !important; /** Use important only in very rare situations **/
}
p b {
color: initial;
}
<div>
<p>
<b>Hello there, welcome</b>
<br/>
To this website
</p>
<p>Some other text</p>
</div>
编辑: 要覆盖内联样式,您可以在 css.
中使用!important