BEM block, naming & nesting

后端 未结 3 1645
忘了有多久
忘了有多久 2020-12-02 05:14

I am trying to wrap my head around BEM naming convention. I am stuck at this. I may misunderstanding something, lets see.

I have a sidebar nav and a content nav.

3条回答
  •  庸人自扰
    2020-12-02 05:41

    Consider idea of _key_value pairs for modifiers (block or element is separated from modifier name with one underscore and its value with another one).

    That makes sense to distinguish modifiers one from another (e.g. nav_type_content and nav_type_sidebar are both about the place where nav apper on the page but modifiers setting theme, size or making links work via ajax are different) and so to understand which modifiers can't be used together on one DOM-node.

    Also it's more convenient to work with key: value pairs in javascript.

    And there are quite a lot of ready-made components and tools which uses such convention: https://github.com/bem/

提交回复
热议问题