我有一些 SCSS 代码来样式化列表项。我的疑问是关于类和伪选择器的选取顺序。简单来说,&:before.active
是否等同于 &.active:before
?
这里是后者的完整示例:
.sidebar-list {
list-style-type: none;
padding: 0;
& li {
padding: 4px 0;
&:before { // Here,
color: darken($font-color, 60%);
font-family: "FontAwesome";
content: "\f101\00a0";
}
&.selected:before { // And here.
color: darken($font-color, 30%);
}
}
}
以下是需要关注的部分(位于 li
中):
&:before { // Here,
color: darken($font-color, 60%);
font-family: "FontAwesome";
content: "\f101\00a0";
&.selected { // And here. This would evaluate to "li:before.selected"
color: darken($font-color, 30%);
}
}
哪种方法是正确的为列表项样式化:before
伪选择器?
谢谢!
::
。 (我查了一下确保无误:https://dev59.com/flgR5IYBdhLWcg3wBZS3#41867706)谢谢!这是一个好答案。 - Jacob Birkett