如图,如果像选择类名为 class=exerciseInfo 中的第一个和最后一个div,做法如下:
选择第一个类名: .exerciseInfo: nth-of-type(1) { ... };
选择最后一个类名: .exerciseInfo: last-child { ... };
选择其中一个指定的类名:.exerciseInfo: nth-of-type(x) { ... };
-------------------------注:不要使用nth-child(x)来选择,无效!-------------------------------
选择
第一个
类名: .demo .item: nth-of-type(1) { … } || .demo .item: nth-child(1) { … };
选择
最后一个
类名: .demo .item: last-child { … };
选择
其中一个指定的类名:.demo .item: nth-of-type(x) { … } || .demo .item: nth-child(x) { … };
那么nth-of-type与nth-child 什么区别呢
:n...