Answer the question
In order to leave comments, you need to log in
How to get rid of nesting according to BEM?
There is a small code in js and css
(function($){
$(function() {
$('.menu__icon').on('click', function() {
$(this).closest('.menu').toggleClass('menu_state_open');
});
});
})(jQuery);
.menu.menu_state_open .menu__icon span:nth-child(1) {
top: 18px;
width: 0%;
left: 50%;
}
.menu.menu_state_open .menu__icon span:nth-child(2) {
transform: rotate(45deg);
}
.menu.menu_state_open .menu__icon span:nth-child(3) {
transform: rotate(-45deg);
}
.menu.menu_state_open .menu__icon span:nth-child(4) {
top: 18px;
width: 0%;
left: 50%;
}
.menu.menu_state_open .menu__links {
opacity: 1;
}
Answer the question
In order to leave comments, you need to log in
When modifying a block, it is quite possible to use a cascade. BEM doesn't forbid the cascade, but recommends avoiding it, and using it where you're sure it won't be a problem. In your case, this is a valid bam.
From the Yandex code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question