Why is the first div red, but not the other? If you enable SCSS preprocessor in the pen, both divs are red as expected.
.regular {
html & {
color: red;
}
}
.pseudo:before {
content: '(pseudo) style me red';
html & {
color: red;
}
}
<div class="regular">(regular) style me red</div>
<div class="pseudo"></div>
Why is the first div red, but not the other? If you enable SCSS preprocessor in the pen, both divs are red as expected.
https://codepen.io/aeharding/pen/wvVLBZg
.regular {
html & {
color: red;
}
}
.pseudo:before {
content: '(pseudo) style me red';
html & {
color: red;
}
}
<div class="regular">(regular) style me red</div>
<div class="pseudo"></div>
Share
Improve this question
edited Nov 20, 2024 at 7:49
Temani Afif
274k28 gold badges365 silver badges485 bronze badges
asked Nov 20, 2024 at 7:45
aehardingaeharding
5981 gold badge4 silver badges18 bronze badges
2 Answers
Reset to default 2It's by design but it may change in the future: https://github/w3c/csswg-drafts/issues/7433
From the actual Specification:
The nesting selector cannot represent pseudo-elements
.regular {
html & {
color: red;
}
}
.pseudo:before {
content: '(pseudo) style me red';
html & {
color: red;
}
}
<div class="regular">(regular) style me red</div>
<div class="pseudo"></div>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742373996a4431821.html
评论列表(0条)