CSSで順番を指定

css

***-childは要素すべての順番を指定
***-of-typeは特定の要素の順番を指定

種類 -child -of-type
最初 :first-child :first-of-type
最後 :last-child :last-of-type
前からX番目 :nth-child(X) :nth-of-type(X)
後ろからX番目 :nth-last-child(X) :nth-last-of-type(X)
1個だけ :only-child :only-of-type

nth-***
X番目:nth-***(X)
Xの倍数:nth-***(Xn)
奇数:nth-***(odd)
偶数:nth-***(even)

nth-last-***
後ろから指定:nth-last-***

その他
***以外:not(***)
1個だけ要素がある:only-***
子要素がない:empty

Xの倍数の次:nth-***(Xn+1)
X番目から最後まで(X番目以降):nth-***(n+X)
最初からX番目まで(X番目以前):nth-***(-n+X)
最後からX番目以前:nth-last-***(n+X)
最後からX番目まで:nth-last-***(-n+X)

タイトルとURLをコピーしました