我到萨斯重构这些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)
我应该如何重构这些选择?