yuheijotaki.com

2015/12/30 : 
CSSスニペット

たまに使うけどそらで思い出せないもの

/* 最初 */
:first-child
:first-of-type

/* 最後 */
:last-child
:last-of-type

/* X番目 */
:nth-child(X)
:nth-of-type(X)

/* Xの倍数 */
:nth-child(Xn)

/* 最後からX番目 */
:nth-last-child(X)
:nth-last-of-type(X)

/* X番目以降 */
:nth-child(n+X)

/* X番目以前 */
:nth-child(-n+X)
:nth-of-type(-n+X)

/* 最後からX個 */
:nth-last-child(-n+X)
:nth-last-of-type(-n+X)

/* 最後からX番目以前 */
:nth-last-child(n+X)
:nth-last-of-type(n+X)

/* 奇数 */
:nth-child(odd)

/* 偶数 */
:nth-child(even)

/* 属性 */
input[type="text"]

 

参考