W
W
WQP2016-12-16 14:23:52
css
WQP, 2016-12-16 14:23:52

Is it correct to write like this (bem)?

The subject
itself

<!-- .header -->
<section class="header">
    <div class="container">
        <div class="header__top">
           <div class="header__logotype">
               <a href="#" class="header_logotype_link">
                   <img src="_tmp/logotype.png" alt="Casino" class="header_logotype_image">
               </a>
           </div>
        </div>
    </div>
</section>
<!-- /.header -->

scss
.header {
    &__top {

    }

    &__logotype {
        &_link {

        }

        &_image {

        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Kit, 2016-12-16
@WQP

No, it's wrong.
BEM is needed to avoid nesting. That's right

.header {
    $parent: &;
    &__top {

    }

    &__logotype {
    }
    #{$parent}_link {

    }

     #{$parent}_image {

    }
}

UPD:
In short, according to bam, there should be something like this in scss.
Although here svg is not according to BEM, but this is because when loading new svg, I do not want to climb into each one and add an element class.
202dde9b517b4c14a14b903942b6c9a1.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question