/*p的父元素下的p元素,p元素是倒数第二个子元素*/p:nth-last-child(2){背景色:红色;}/*p的父元素下的倒数第二个p元素*/p:nth-last-of-type(2){background-color:blue;}12345
1
2
3
4
nth-last-child()和nth-last-of-type()的用法和区别相关文章