正确使用块和修饰符

时间:2019-02-11 07:44:41

标签: css bem

我在一个网站上实现了ABEM(具有原子设计命名系统的BEM的替代品),现在经过长时间的编码狂潮,我的大脑非常模糊……我有一个命名问题<div>

我有一个命名为.a-pipe的块,其中包含一些文本和样式。然后,由于使用了许多不同的“管道”变体,因此我现在使用修饰符设置样式以更改其颜色。因此:.--grey.--blue.--green。现在,有了这个,以及我对使用块,元素和修饰符的困惑,我陷入了停顿的问题:.a-pipe应该是一个块,如果是,该块的变体是否应该有修饰符改变颜色和其他样式?

HTML:

<div class="a-pipe --grey">some normal text <span class="a-pipe --lgText">Some larger text</span></div>

<div class="a-pipe --green">some normal text <span class="a-pipe --lgText">Some larger text</span></div>

CSS:

.a-pipe {
 padding: 10px 3.5rem 10px 0;
 border-radius: 0px 10rem 10rem 0px / 0px 8.1rem 8.1rem 0px;
 text-align: right;
 color: white;
}

.a-pipe.--green {
 background-color: green;
}

0 个答案:

没有答案
相关问题