【发布时间】:2017-11-27 09:38:19
【问题描述】:
这里我有 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 psuedo-selector 样式,哪一个是正确的?
谢谢!
【问题讨论】:
标签: css sass css-selectors