我到薩斯重構這些CSS選擇器:薩斯第n個孩子築巢
#romtest .detailed th:nth-child(2),
#romtest .detailed th:nth-child(4),
#romtest .detailed th:nth-child(6),
#romtest .detailed td:nth-child(2),
#romtest .detailed td:nth-child(3),
#romtest .detailed td:nth-child(6),
#romtest .detailed td:nth-child(7),
#romtest .detailed td.last:nth-child(2),
#romtest .detailed td.last:nth-child(4) {
background:#e5e5e5;
}
...以及與此想出了:
#romtest .detailed {
th:nth-child {
&(2), &(4), &(6) {
background:#e5e5e5;
}
}
td:nth-child {
&(2), &(3), &(6), &(7) {
background:#e5e5e5;
}
}
td.last:nth-child {
&(2), &(4) {
background:#e5e5e5;
}
}
}
不幸的是,這是拋出一個錯誤:
Invalid CSSS after "&": expected "{", was "(2), &(4), &(6) {"
我也知道這可能會更好,因爲我是:
- 重複的背景顏色
- 重複號碼 - 即(2)和(6)
我應該如何重構這些選擇?