first-child:第一個元素
li:first-child{
color:red;
}
li標簽作為第一個元素時,文字元素設置為紅色。
last-child:最后一個元素
li:last-child{
color:orange;
}
li標簽作為最后一個元素時,文字顏色設置為橙色。
nth-child()
li:nth-child(2){
color:green;
}
li標簽作為第二個元素時,文字顏色設置為綠色。
nth-last-child()
li:nth-last-child(2){
color:red;
}
li標簽倒敘作為第二個元素時,文字顏色設置為紅色。