我有这样的SASS代码:
li {
&:last-child, &.last-child {
color: red;
}
}
和 HTML 代码:
<ul>
<li class="last-child">Hello there!</li>
</ul>
上面的代码在 IE8 中不起作用。我知道 IE8 不支持 :last-child,我为此定义了 .last-child。
当我将 SASS 代码编辑为此:
li {
&:last-child {
color: red;
}
&.last-child {
color: red;
}
}
现在一切正常,但会导致代码重复。
我正在为带有 JS 功能的 IE8 添加 .last-child,但我认为这并不重要。