Answer the question
In order to leave comments, you need to log in
How to implement class nesting in SCSS?
There is some markup like this:
<div class="card">
<figure class="card__avatar">
<im class="card-avatar__image" src="" />
</figure>
</div>
.card {
&__avatar {
&__image {
}
}
}
<div class="card">
<div class="card__block">
<div class="card-block__inner">
<div class="card-block-inner__box">
<div class="card-block-inner-box__item">
</div>
</div>
</div>
</div>
</div>
.card {
&__block {
&__inner {
&__box {
&__item {
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
You have already been told in the comments that the approach is terrible and it's all wrong, etc., etc. But if you really really and really want to write bad code, no one will forbid you to do this.
What could be the solution - you can make a variable inside the parent. That is, like this:
.card {
$parent: ".card";
&__avatar {
$avatar: ".#{$parent}-avatar";
#{$avatar}__image {
// ну и далее я думаю подход ясен
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question