M
M
Maxim2020-11-11 10:58:50
HTML
Maxim, 2020-11-11 10:58:50

How to correctly build a SCSS nesting with an active element using the BEM menu?

Menu code, more complex version:

<nav class="menu">
  <ul class="menu__list">
    <li class="menu__item menu__item_state_active">
      <a class="menu__link" href="">
        .menu__icon
        .menu__text
      </a>
    </li>
    <li class="menu__item"><a class="menu__link" href=""></a></li>
    <li class="menu__item"><a class="menu__link" href=""></a></li>
  </ul>
</nav>


What are the other options?
.menu {
  $menu: &;
  &__item {...}
  &__link {color: #ccc;}

/* Для активного элемента */
  &__item {
    &_state_active {
      #{$menu} {
        &__icon {
          fill: #212121;
        }
        &__text {
          color: #212121;
        }
      }
    }
  }
}

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