A
A
Andrey Kvartsov2018-02-21 10:13:14
BEM
Andrey Kvartsov, 2018-02-21 10:13:14

How to write styles according to the BEM methodology?

Good day.
I asked myself a question ... Often a situation arises when, when hovering over 1 block, it is necessary for a block nested in it to have a hover effect, for example .
Are there better solutions than what I do? I'm talking about the piece of code:

&__info {
    width: 300px;
    padding: 30px;
    background: #eee;
   
    &:not(:first-child) {
      margin-left: 15px;
    }
    &:hover {
      cursor: pointer;
      .block__btn {
        cursor: pointer;
        background: #0D76FF;
      }
    }
  }

That is, what I'm doing is essentially a nested selector that compiles to:
.block__info:hover .block__btn {
...
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question