假设有4行中有12个项目.
| 1 || 2 || 3 |
| 4 || 5 || 6 |
| 7 || 8 || 9 |
| 10 || 11 || 12 |
Run Code Online (Sandbox Code Playgroud)
我想选择第二排和第四排,我该怎么做?
请注意,行不在不同的HTML元素中,实际上它们都是ul li元素.
期望的结果:
| 1 || 2 || 3 |
|--4---||--5---||--6---|
| 7 || 8 || 9 |
|--10--||--11--||--12--|
Run Code Online (Sandbox Code Playgroud)
我试过玩这个:
li:nth-child(n+4)
Run Code Online (Sandbox Code Playgroud)
它选择前三个之后的所有元素.然后我尝试了这个:
li:nth-child(n+4):nth-child(-n+8)
Run Code Online (Sandbox Code Playgroud)
这只选择了4,5和6但我不能重复这种模式来选择10,11和12.CSS中有这个解决方案吗?