種類 | -child | -of-type |
---|---|---|
最初 | :first-child | :first-of-type |
最後 | :last-child | :last-of-type |
n番目 | :nth-child(n) | :nth-of-type(n) |
後ろからn番目 | :nth-last-child(n) | :nth-last-of-type(n) |
1個だけ | :only-child | :only-of-type |
X番目からYまで
:nth-child(n+X)
X番目以降(X番目から最後まで)
:nth-of-type(n+X)
ある要素のX番目以降(X番目から最後まで)
:nth-child(-n+X)
X番目以前(最初からX番目まで)
:nth-of-type(-n+X)
ある要素のX番目以前(最初からX番目まで)
最後からX個
:nth-last-child(-n+X)
最後からX個
:nth-last-of-type(-n+X)
ある要素の最後からX個
最後からX番目以前
:nth-last-child(n+X)
最後からX番目以前
:nth-last-of-type(n+X)
ある要素の最後からX番目以前