我有这样BEM从独特的命名到重复元素
<div class="chatlist-container chatlist-container_hidden">
<div class="container-header">
<span class="chatlist-title">
</span>
<div class="container-header__button">
<span class="icon-minus"></span>
</div>
<div class="container-header__button">
<span class="icon-cancel"></span>
</div>
</div>
<dl class="chatlist-container__chatlist">
<div class="chatlist-container__chatgroup">
<p ...
<div ...
</div>
<div class="chatlist-container__chatgroup">
</div>
<div class="chatlist-container__chatgroup">
</div>
</dl>
</div>
凡chatlist-container
是主容器代码,然后去container-header
,它可以在另一个容器中重复使用,所以他叫不依赖chatlist-container__
,然后去chatlist-container__chatlist
,它只存在于chatlist-container
,所以他用他的依赖名称,然后去chatlist-container__chatgroup
,组可以重复,但只存在于chatlist-container
,如何命名他们的孩子,或与依赖chatlist-container
?
我想像这样的chatlist-container__chatgroup-title
和chatlist-container__chatgroup-description
,对吧?但如果是这样的话,如果description
后面会有孩子,他们的命名可能非常棘手而且很长。
另外,如果是的话,如何编写CSS,现在它看起来像:
.chatlist-container { ... .chatlist-container .chatlist-container__chatlist { ... .chatlist-container .chatlist-container__chatlist .chatlist-container__chatgroup { ...
但是,如果我的子元素添加到我的群体,他们的选择也越来越公里长,看起来像这样
.chatlist-container .chatlist-container__chatlist .chatlist-container__chatgroup .chatlist-container__chatgroup-title { ...
谢谢你的回答,我只是想听到比我的其他意见,所以你的答案完全适合,更多的这个我有关于命名聊天组作为独立组件的想法,只是想知道是否有人也这么想,而且会不仅对我来说可以理解和容易支持。 – MyMomSaysIamSpecial