【发布时间】:2019-07-11 20:04:50
【问题描述】:
当我使用 BEM 时,我被简单的场景弄糊涂了。 示例中有一个基本按钮:
.button {
// styles for button
}
及其具有更具体样式的修饰符:
.button.button_run {
// additional styles for this type of button
// i.e. custom width and height
}
有一刻我意识到我需要button_run 的修饰符,让我们将其命名为button_run_pressed:
.button_run_pressed {
// more styles, i.e. darker background color
}
问题在于,根据 BEM 约定,像我在上面 button_run_pressed 所做的那样命名最后一个元素是不正确的。但我只需要为“运行”按钮添加“按下”样式,而不是通过编写 button_pressed 之类的类和混合修饰符 button button_run button_pressed 来添加所有按钮。
我应该如何重构我的代码以匹配 BEM 约定?
【问题讨论】: