【发布时间】:2022-02-21 12:59:07
【问题描述】:
我正在尝试找出我在 BEM 中遇到的这个愚蠢但令人讨厌的问题。目前对于我的应用程序,我遵循 BEM 方法来创建 UI 元素。例如:
<div class="card">
<h2 class="card__title">Sample Title </h2>
<h3 class="card__subtitle"> Sub Title </h3>
<button class="card__action"> Action Button </button>
</div>
这个的 scss 将是:
.card{
&__title{color:red}
&__subtitle{color:violet}
&__subtitle{bakground:black}
}
现在,如果我需要添加卡片的新变体,我会将其添加为“card--modifier”。
.card{
&--variant{background-color:white}
&__title{color:red}
&__subtitle{color:violet}
&__subtitle{bakground:black}
}
现在,不破坏 scss 中的这种嵌套,如何修改子变体下的属性?
【问题讨论】: