-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_nth_child.html
73 lines (66 loc) · 1.33 KB
/
02_nth_child.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>nth Child</title>
<style>
li {
padding: 0.25rem;
margin: 0.25rem;
list-style: none;
}
/* first-child */
li:first-child {
background: red;
}
li:last-child {
background: red;
}
/* Position 3 */
li:nth-child(5) {
background: purple;
}
/* Every 3 */
li:nth-child(3n+0) {
background: orange;
}
/* Every 3 after 7 */
li:nth-child(3n+7) {
background: yellow;
}
/* Every odd */
li:nth-child(odd) {
background: #ccc;
}
/* Every even */
li:nth-child(even) {
background: #ddd;
}
</style>
</head>
<body>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
<li>Item 9</li>
<li>Item 10</li>
<li>Item 11</li>
<li>Item 12</li>
<li>Item 13</li>
<li>Item 14</li>
<li>Item 15</li>
<li>Item 16</li>
<li>Item 17</li>
<li>Item 18</li>
<li>Item 19</li>
<li>Item 20</li>
</ul>
</body>
</html>