如何實(shí)現(xiàn)前三個(gè)child變色,只能寫3次嗎?
li:nth-child(1),nth-child(2),nth-child(3){background:green;}
只能這樣嗎? 如果20個(gè)元素 前10個(gè)變色就得寫10次嗎
li:nth-child(1),nth-child(2),nth-child(3){background:green;}
只能這樣嗎? 如果20個(gè)元素 前10個(gè)變色就得寫10次嗎
2020-12-31
舉報(bào)
2020-12-31
我百度到了 可以是li:nth-child(-n+3):nth-child(n+1){background:green;}