gpt4 book ai didi

css - :last-child works, :first-child 没有

转载 作者:太空狗 更新时间:2023-10-29 15:30:10 26 4
gpt4 key购买 nike

<分区>

我有一个 aside有两个<div class="sku">元素。我正在尝试使用 CSS 来操纵 :first-child但它不起作用。但是,在尝试访问 :last-child 时确实如此。

JSFiddle

HTML

<aside>
<h1>Product Name</h1>
<div class="sku">
<h3>
100 – Small
</h3>
<div class="dimension">
<ul>
<li>
<span class="title">
Product Dimensions
</span>
<span class="specs">
23.75w
x
17.75h
x
28d
</span>
</li>
</ul>
</div>
</div>
<div class="sku">
<h3>
200 – Large
</h3>
<div class="dimension">
<ul>
<li>
<span class="title">
Product Dimensions
</span>
<span class="specs">
29.75w
x
17.75h
x
28d
</span>
</li>
</ul>
</div>
</div>
</aside>

CSS

.sku:first-child { 
display:none !important; /*doesn't hide the first child*/
}

.sku:last-child {
display:none !important; /*does hide the first child*/
}

为什么不会:first-child选择第一个 div?

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