K
K
Konstantin2019-06-25 12:47:39
Sass
Konstantin, 2019-06-25 12:47:39

BEM styles in sass - how to do it right?

I write this code in SASS

.main-header
  &__navigation-items
    padding: 0
    margin: 0
    list-style: none
  &__navigation-item
    padding: 10px
    margin: 0
    display: inline-block
    text-transform: uppercase
    a
      text-decoration: none
      color: $text-color
    &--active
      padding: 10px
      margin: 0
      display: inline-block
      text-transform: uppercase
      a
        text-decoration: none
        color: $main-color

It's normal to write like this, but how is it a lot of the same code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tema_sun, 2019-06-25
@KOSTDM

In general, BEM assumes the almost complete absence of a cascade. Those. instead of a selector .main-header__navigation-item a, there should be one .main-header__navigation-link.

K
Konstantin, 2019-06-25
@KOSTDM

then for
do not apply styles
padding: 10px
margin: 0
display: inline-block
text-transform: uppercase
https://codepen.io/anon/pen/PrKwxJ

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question