nth-child和nth-of-type以及last-*的区别

nth-child

1

2

3

4

5

6
7
8
9

nth-last-child

1

2

3

4

5

6
7
8
9

nth-of-type

1

2

3

4

5

6
7
8
9

nth-last-of-type

1

2

3

4

5

6
7
8
9

nth-child

1

2

3

4

5

6
7
8
9

nth-of-type

1

2

3

4

5

6
7
8
9
其实区别很简单:
“with the same expanded element name”

而last-*简单理解就是倒序:
“after it in the document tree”
默认是:
“before it in the document tree”

计算方法同样是an+b-1,并允许取值为odd或even

详细介绍:http://www.w3.org/TR/css3-selectors/#nth-child-pseudo