Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 在特定子模式之后开始的第n个子模式_Css_Css Selectors_Styles - Fatal编程技术网

Css 在特定子模式之后开始的第n个子模式

Css 在特定子模式之后开始的第n个子模式,css,css-selectors,styles,Css,Css Selectors,Styles,如何创建第n个子模式,如下所示: div:nth-child(3n+1){ background: #FF7100; } div:nth-child(3n+2){ background: #FFB173; } div:nth-child(3n+3){ background: #A64A00; } 但要跳过第一个子项,只在第一个子项之后启动此模式。我试着像下面那样将其链接起来,但似乎不起作用: div:nth-child(n+1):nth-child(3n+1) {

如何创建第n个子模式,如下所示:

div:nth-child(3n+1){
   background: #FF7100;
}
div:nth-child(3n+2){
   background: #FFB173;
}
div:nth-child(3n+3){
   background: #A64A00;
}
但要跳过第一个子项,只在第一个子项之后启动此模式。我试着像下面那样将其链接起来,但似乎不起作用:

 div:nth-child(n+1):nth-child(3n+1) {
    background: #FF7100;
}
使用
:not(:first child)
选择器跳过第一个子项

div:not(:第一个子项):第n个子项(3n+1){
背景:FF7100;
}
分区:第n个子(3n+2){
背景:#FFB173;
}
分区:第n个子(3n+3){
背景:#A64A00;
}
1
2.
3.
4.
5.
6.
7.
8.
9

10
Pugazh的答案是更好的答案,但只是为了解释为什么您最初的尝试没有成功(我是全新的,没有足够的代表来评论)

在CSS选择器中,
n
从0开始,因此第n个子元素(n+1)仍在选择第1个
(0+1)元素,因此第n个子元素(n+2)
将使用您的方法工作