Answer the question
In order to leave comments, you need to log in
Why in BEM so-called. "first nesting level", i.e. "block_element"?
Tell me why in BEM the so-called. "first nesting level", i.e. "block_element"?
What is the difficulty in having only elements or only blocks (whatever you call them) that are nested and have modifiers?
Why all this circus with double underlining and supposedly nesting, but a ban on its use?
The ban is clear to me - due to the fact that browsers sort styles by nesting level - the more - the later they will be applied, the ban is justified, that is, use it carefully.
And why introduce a double underscore, if the element can be with the specified parent as a modifier?
BEM:
.calculator {}
.calculator__button {}
.calculator__button_theme_material {}
.calculator__button_color_red {}
.calculator {}
.button {}
.button_theme_material {}
.button_color_red {}
ИЛИ:
.calculator .button {} (ЧТО БЭМ НЕ РЕКОМЕНДУЕТ...)
ИЛИ:
.button_parent_calculator {}
.calculator_theme_material {}
.button_theme_material {}
.calculator__button_theme_material {}
.select_theme_material {}
.calculator__select_theme_material {}
.select__button_theme_material {}
.select__field_theme_material {}
.select__hiddeninput_theme_material {}
.select__input_theme_material {}
....blablabla_theme_material {};
.calculator {}
.calculator_theme_material {}
.calculator .button {}
.calculator_theme_material .button {}
If you write on Bitrix, you are cool. Just got to deal with the fact that he's awful.
Answer the question
In order to leave comments, you need to log in
my IMHO, bam is needed only so that any block can be cut and pasted anywhere and not break the css at the same time, with your example:
.calculator__button {}
and if it’s the same for the buttons, you will have 10 variations, when you transfer it, it may be difficulties.
.calculator .button
in general, I see the point in this technology only in ultra-large projects and sites with 100,500 hand-made pages that are constantly changing.
BEM is about block independence, that's all. Should I join a sect? Everyone decides for himself. Any small site / landing or something larger can live very comfortably without a bem, this is a fact.
At some point, I myself decided that it was better to have some kind of methodology, and bem has no serious alternatives today, I had to join. As for code redundancy, classes there and all that, cool dudes don’t write with pens, they use the full stack from Yandex. I just wrote a wrapper for pug and made my gulp build.
Let's say I did as you wrote:
.calculator {}
.calculator_theme_material {}
.calculator .button {}
.calculator_theme_material .button {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question