Answer the question
In order to leave comments, you need to log in
BEM. How to implement nesting of blocks of the same type into each other without overlapping styles?
There is a component:
<table class="table">
<tbody class="table__body">
<tr class="table__row">
<td class="table__cell">
...
</td>
</tr>
</tbody>
</table>
.table {
&__body { }
&__row { }
&__cell { }
&_dark &__cell {
background: black;
color: white;
}
}
<td class="table__cell">
<modal title="Редактировать">
<table class="table">
<tbody class="table__body">
<tr class="table__row">
<td class="table__cell">
...
</td>
</tr>
</tbody>
</table>
</modal>
</td>
.table {
...
&_dark > &__body > &__row > &__cell {
background: black;
color: white;
}
}
<table class="table table_dark">
...
<td class="table__cell">
...
<table class="table table_default">
...
</table>
</td>
</table>
.table {
&_default {
&__body { }
&__row { }
&__cell { }
}
&_dark {
&__body { }
&__row { }
&__cell {
background: black;
color: white;
}
}
}
&_default &__body,
&_dark &__body {
...
}
&_default &__cell,
&_small &__cell {
...
}
Answer the question
In order to leave comments, you need to log in
Probably it should be done something like this:
Styles that do not change are written to a block or element
Styles that are changed are written to modifiers
All blocks and elements are always used with modifiers
It will turn out something like this https://jsfiddle.net/termitkin /as0vLjo1/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question