P
P
Polina2018-01-09 11:58:26
BEM
Polina, 2018-01-09 11:58:26

Is it possible in BEM to use the same modifier for a block and an element?

Can you please tell me how to correctly lay out such blocks according to BEM:
There are blocks of the same type, they differ only in the mutual arrangement of elements, as in the example:
https://jsfiddle.net/b19chkdf/
I made a modifier for each block block - block_dir_row and block_dir_column. The problem is that some elements (.block__title) should have different margins, in the attached fiddle - 2 and 20 pixels. According to BEM, the external geometry is set through the parent block. But they have the same parent block. So far, I've done this: I've given them the same modifiers as the parents, and made indents through them (see fiddle). Is it correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2018-01-09
@sim3x

The block name already looks strange, but no
one forbids the use of css nesting

.block__dir-row  .block__title {}
.block__dir-col  .block__title {}

imo it will be so
/* .dir-row */  .dir-row__title {}
/* .dir-col */  .dir-col__title {}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question