gpt4 book ai didi

jQuery/CSS - 如何设置元素在另一个元素中首次出现的样式?

转载 作者:技术小花猫 更新时间:2023-10-29 12:44:20 27 4
gpt4 key购买 nike

这是我的问题。

HTML

<div id="content">
<h1>Headline</h1>
<p>First paragraph that needs to be yellow.</p>
<p>Second paragraph that need not change. :) </p>
<p>Third paragraph that need not change. :) </p>
</div>

如果我使用 #content p:first-child {color:yellow; } 它不起作用,因为 p 不是 content 的第一个 child ... h1 是第一个出生的.

如何在不触及 HTML 代码的情况下执行此操作?

谢谢!

祝一切顺利,克里斯

最佳答案

css3 解决方案

#content > p:first-of-type { color: yellow; }

关于jQuery/CSS - 如何设置元素在另一个元素中首次出现的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5722177/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com