問題描述
我有九組配色方案,我想將它們應用于一系列 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.
這可能嗎,還是我應該在寫出每個 div 時只為它們應用一個類?
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-子 CSS 選擇器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!