:nth-of-type cssセレクタ おさらい

:nth-of-typeの使い方

.blog_box_all

section

div

.class titel

a

テキスト

/a
/div
/section
/div

のループだとすれば

2番目タイトルのカラーを変えたい場合

.blog_box_all section:nth-of-type(2) .blog_titel a {

		color: #F90!important;

}

こうすっべ

偶数を変えたい場合

.blog_box_all section:nth-of-type(2n) .blog_titel a {

		color: #F90!important;

}

奇数

.blog_box_all section:nth-of-type(2n+1) .blog_titel a {

		color: #F90!important;

}

(n) ・・・ n番目の要素に適用

(odd) ・・・ 奇数番目の要素に適用
(2n+1) ・・・ 奇数番目の要素に適用

(even) ・・・ 偶数番目の要素に適用
(2n) ・・・ 偶数番目の要素に適用

(3n) ・・・ 3,6,9,12…番目の要素に適用
(3n+1) ・・・ 1からはじめて+3ずつの番の要素,4,7,10…番目の要素に適用