Answer the question
In order to leave comments, you need to log in
Primary parent via ampersand (SASS). How?
Good time!
I am learning how to use BEM correctly in my projects.
There is a button with an icon and text.
I want to indent the left of the text if there is an icon, i.e. like .btn__ico + .btn__text:
// example 1
.btn
&__ico
position: absolute
&__ico + &__text
margin-left: 29px
// example 2
.btn
&__ico
position: absolute
+ .btn__text
margin-left: 29px
.btn
&__ico
position: absolute
& + &__text
margin-left: 29px
Answer the question
In order to leave comments, you need to log in
Personally, I always use the second option.
Your attempt doesn't work because & refers to the parent, so when you try to write &__text in a &__ico block, you write something like this: &__ico__text.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question