1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
<!DOCTYPE html>
<html>
<head>
<title>:nth-child test</title>
<style>
/** We have weird spacing inside parentheses to test parser. */
.odd > div:nth-child(odd ),
._2n-plus-1 > div:nth-child(2n+1),
.even > div:nth-child( even),
._2n > div:nth-child( 2n ),
._3n > div:nth-child(3n),
._2 > div:nth-child(2 ),
._3n-plus-1 > div:nth-child( 3n + 1 ),
._3n-minus-1 > div:nth-child( 3n -1),
._minus-n-plus-3 > div:nth-child(-n+ 3),
.n > div:nth-child(n), /** "n" is special case inside parser. */
.plus-n > div:nth-child(+n), /** "+n" is special case inside parser. */
.minus-n > div:nth-child(-n), /** "-n" is special case inside parser. */
._0n-plus-1 > div:nth-child(-0n+1),
.n-plus-2__minus-n-plus-4 > div:nth-child(+n + 2 ):nth-child( -n+4) {
background-color: lightblue;
}
</style>
</head>
<body>
<h4>:nth-child(odd)</h4>
<div class="odd">
<div>1 +</div>
<div>2</div>
<div>3 +</div>
<div>4</div>
</div>
<h4>:nth-child(2n+1) - same as odd</h4>
<div class="_2n-plus-1">
<div>1 +</div>
<div>2</div>
<div>3 +</div>
<div>4</div>
</div>
<h4>:nth-child(even)</h4>
<div class="even">
<div>1</div>
<div>2 +</div>
<div>3</div>
<div>4 +</div>
</div>
<h4>:nth-child(2n) - same as even</h4>
<div class="_2n">
<div>1</div>
<div>2 +</div>
<div>3</div>
<div>4 +</div>
</div>
<h4>:nth-child(2)</h4>
<div class="_2">
<div>1</div>
<div>2 +</div>
<div>3</div>
</div>
<h4>:nth-child(3n)</h4>
<div class="_3n">
<div>1</div>
<div>2</div>
<div>3 +</div>
<div>4</div>
<div>5</div>
<div>6 +</div>
</div>
<h4>:nth-child(3n+1)</h4>
<div class="_3n-plus-1">
<div>1 +</div>
<div>2</div>
<div>3</div>
<div>4 +</div>
<div>5</div>
<div>6</div>
</div>
<h4>:nth-child(3n-1)</h4>
<div class="_3n-minus-1">
<div>1</div>
<div>2 +</div>
<div>3</div>
<div>4</div>
<div>5 +</div>
<div>6</div>
</div>
<h4>:nth-child(-n+3)</h4>
<div class="_minus-n-plus-3">
<div>1 +</div>
<div>2 +</div>
<div>3 +</div>
<div>4</div>
</div>
<h4>:nth-child(n)</h4>
<div class="n">
<div>1 +</div>
<div>2 +</div>
<div>3 +</div>
</div>
<h4>:nth-child(-n) - same as n</h4>
<div class="n">
<div>1 +</div>
<div>2 +</div>
<div>3 +</div>
</div>
<h4>:nth-child(+n) - same as n</h4>
<div class="n">
<div>1 +</div>
<div>2 +</div>
<div>3 +</div>
</div>
<h4>:nth-child(0n+1)</h4>
<div class="_0n-plus-1">
<div>1 +</div>
<div>2</div>
<div>3</div>
</div>
<h4>:nth-child(n+2):nth-child(-n+4)</h4>
<div class="n-plus-2__minus-n-plus-4">
<div>1</div>
<div>2 +</div>
<div>3 +</div>
<div>4 +</div>
<div>5</div>
</div>
</body>
</html>
|