gpt4 book ai didi

html - 如果最后一个元素是四的倍数,css 选择最后四个,如果是 3 的倍数,则最后一个 3

转载 作者:太空宇宙 更新时间:2023-11-04 08:13:54 24 4
gpt4 key购买 nike

我有以下 css 来获取最后四个

:nth-last-child(-n+4){border-bottom: none;}

它返回给我这个结果:

enter image description here

在此,最后四个 child 都没有边框底部

但是,如果最后一项是 3 的倍数,则它会转到上一行。

enter image description here

我需要的是:

  1. 当最后一项是3的倍数时,只选择最后3 enter image description here
  2. 当最后一项是2的倍数时,只选择最后2 enter image description here

此外,这需要使用纯 CSS。有谁知道如何实现这一点?

最佳答案

这将需要一些非常复杂的选择器,与找到的选择器没有什么不同 here , 但它可以做到:

:first-child:nth-last-child(4n) ~ :nth-last-child(-n+4),
:first-child:nth-last-child(4n+3) ~ :nth-last-child(-n+3),
:first-child:nth-last-child(4n+2) ~ :nth-last-child(-n+2) {
border-bottom: none;
}

关于html - 如果最后一个元素是四的倍数,css 选择最后四个,如果是 3 的倍数,则最后一个 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46046986/

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