回答編集履歴

1

コード追加

2020/06/16 05:22

投稿

hatena19
hatena19

スコア33740

test CHANGED
@@ -22,4 +22,26 @@
22
22
 
23
23
 
24
24
 
25
- h2 の後に p要素とか別の要素が続くなら :nth-child では難しいかと。
25
+ h2 の後に p要素とか別の要素が続くなら :nth-child では難しいかと。:nth-of-typea
26
+
27
+ を使うといいでしょう。
28
+
29
+
30
+
31
+ ```css
32
+
33
+ h2 {
34
+
35
+ background-color: #ad1452;
36
+
37
+ }
38
+
39
+
40
+
41
+ h2:nth-of-type(4n-1), h2:nth-of-type(4n){
42
+
43
+ background-color: #2d4084;
44
+
45
+ }
46
+
47
+ ```