gpt4 book ai didi

css - 根据类名选择第一个元素 css

转载 作者:行者123 更新时间:2023-11-28 17:59:51 25 4
gpt4 key购买 nike

.class + p:first-child{

}

上面的代码不起作用,除非它是元素而不是类,比如 p:first-child。

<div class="wrap">
<h3></h3>
<div style="clear:both"></div>
<p></p>
<p></p>
<p></p>
<p></p>

如何根据类包装选择第一个 p?我不想在 p 上应用类名。

最佳答案

您不能使用 :first-child在这里,因为在这种情况下 first-childclass:wrap<h3> .在你想要的情况下试试这个

.wrap > p:nth-of-type(1) {
color:red

}

fiddle 是 HERE

关于css - 根据类名选择第一个元素 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20674087/

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