gpt4 book ai didi

html - 如何使用头胎?

转载 作者:太空宇宙 更新时间:2023-11-03 21:40:56 25 4
gpt4 key购买 nike

我想选择第一个名为“aProduct”的 div,但我对如何执行此操作有点困惑。我已经试过了:

<div id="kasticketProducts">
<div class="aProductHeader"></div>
<div class="aProduct"></div>
<div class="aProductHeader"></div>
<div class="aProduct"></div>
</div>

这是我当前的 CSS:

#kasticketProducts:first-child .aProduct {
margin-top: 30px;
background: red;
}

最佳答案

#kasticketProducts:first-child .aProduct使用上面的 css 意味着首先它将在第一个 child 中搜索带有 kasticketproducts 的 id,这里第一个 child 从这里引用 aProductHeader,您正在尝试搜索 aProduct 但它不在那里。实际上,从 DOM 层次结构来看,aProduct 类 div 位于第二个子级,这将在 css 中称为 nth-child(2) 并且不需要再次使用 .aProduct 。所以最终的解决方案是写为 #kasticketProducts div:nth - child (2)

关于html - 如何使用头胎?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23651578/

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