Nth-Child CSS选择器 [英] Nth-Child CSS Selectors

查看:201
本文介绍了Nth-Child CSS选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有九组颜色方案,我想应用于一系列的div。使用:nth-​​child(1),:nth-​​child(2)... 适用于前九个,但我想要序列,然后重复之后,我不能把我的头围绕在(3n + 2)符号...我想我得到它,但我似乎不能哄它做我想要的。

I have nine sets of color schemes that I want to apply to a sequence of divs. Using :nth-child(1), :nth-child(2)... works for the first nine, but I'd like the sequence to then repeat after that, and I can't wrap my head around the (3n+2) notation... I think I get it, but I can't seem to coax it into doing what I want. Is this possible, or should I just apply a class to each div as I write them out?

谢谢!

推荐答案

如果你需要对每九个连续的元素应用不同的规则,你必须使用这九个选择器:

If you mean you need to apply different rules to every nine consecutive elements, you have to use these nine selectors:

:nth-child(9n+1)
:nth-child(9n+2)
:nth-child(9n+3)
:nth-child(9n+4)
:nth-child(9n+5)
:nth-child(9n+6)
:nth-child(9n+7)
:nth-child(9n+8)
:nth-child(9n+9) /* Or :nth-child(9n) */

这篇关于Nth-Child CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆