gpt4 book ai didi

css - 使用 nth-child 减少最后 4 个容器

转载 作者:太空宇宙 更新时间:2023-11-03 23:42:44 24 4
gpt4 key购买 nike

我的主页上列出了很多产品,我使用第 nth-child 元素定位最后 4 个以将底部边距减少到 0 但似乎不起作用,以为它是第 nth- child(5), nth-child(6) 等

直播网址 ( http://bit.ly/1gwfpNF )

这是一个片段

#layout #categories .box-1:nth-child(5) { margin-bottom: 0px; }
#layout #categories .box-1:nth-child(6) { margin-bottom: 0px; }
#layout #categories .box-1:nth-child(7) { margin-bottom: 0px; }
#layout #categories .box-1:nth-child(8) { margin-bottom: 0px; }

最佳答案

就像我昨天学到的,你可以这样做:

#layout #categories a:nth-last-of-type(-n+4) .box-1 {
margin-bottom: 0;
}

nth-child 在父项内部计数,因此当您寻找 .boxnth-child 时,它将在你的情况下永远只有一个 child 。

关于css - 使用 nth-child 减少最后 4 个容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22404888/

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