nth-子 CSS 选择器
- 作者: 鄙视你乐园
- 来源: 51数据库
- 2022-10-20
问题描述
我有九组配色方案,我想将它们应用于一系列 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) */
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
