css 控制子元素
这个用来调整第一个元素
:first-child{background:#ff0000;}
这个用来控制指定元素
:nth-child(3){background:#ff0000;}
也可以这样写
:nth-child(3n){background:#ff0000;}
控制最后一个
:last-child{background:#ff0000;}
倒着数第二个,也是可以这样控制的
:nth-last-child(2){background:#ff0000;}
这个是说第二个指定元素
(PS:上面的是第二个元素,以下为第二个指定元素,注意,不一样的。)
p:nth-of-type(2) { color: red; }