2017-09-05 20 views
0

我有以下css来获得最后四个CSS选择过去四年,如果最后一个元素是四个多,如果3的倍数的最后3

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

,并返回我这样的结果:

enter image description here

在此,所有过去的四个孩子没有边框底部

但是,如果最后一项是3的倍数,它涉及到以前行。

enter image description here

我需要的是:

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

此外,这需要在纯粹的CSS。有人知道如何做到这一点?

回答

1

这将需要一些相当令人费解的选择不是不像那些发现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; 
} 
0

而不是使用边框底部,

,我认为你应该改变边境之上,它是适合你的情况。

+1

不,这不是 - 如果底部边框改为顶部边框,就没有下边框第二行最后一行没有任何元素的元素。 – BoltClock

相关问题