Answer the question
In order to leave comments, you need to log in
Bam and Preprocessors?
Is this format acceptable?
Namely "&_bank &-img ?
Or it would be more correct:
&__payment_bank &__payment-img {
background: url('../img/general/bank_creditCard.svg') no-repeat;
width: 18px;
height: 16px;
}
<a href="#" class="checkout__payment checkout__payment_bank">
<div class="checkout__payment-img"></div>
<span>PAY WITH <br>bank card</span>
</a>
<a href="#" class="checkout__payment checkout__payment_paypal">
<div class="checkout__payment-img"></div>
<span>PAY WITH <br>paypal</span>
</a>
.checkout {
background-color: rgba(255, 255, 255, 0.988);
box-shadow: 0 1px 5px 1px rgba(0, 0, 0, 0.1);
padding: 4rem 1.5rem;
&__payment {
text-align: center;
width: 100px;
border: 1px solid #1e88e5;
border-radius: 3px;
padding: .6rem 0;
line-height: 1;
&_bank &-img {
background: url('../img/general/bank_creditCard.svg') no-repeat;
width: 18px;
height: 16px;
}
&_paypal &-img {
background: url('../img/general/bank_paypal.svg') no-repeat;
width: 18px;
height: 16px;
}
... и тд
}
}
Answer the question
In order to leave comments, you need to log in
There are no rules or recommendations in BEM on how you should format your code in scss/less/styl and other style files that are processed by preprocessors.
The first option will return .checkout_bank .chexkout-img, that is, a nested selector, if you want to get such a .checkout_bank-img selector (with a modifier), then the correct way is:
.checkout {
&_bank{
&-img
}
}
.checkout {
background-color: rgba(255, 255, 255, 0.988);
box-shadow: 0 1px 5px 1px rgba(0, 0, 0, 0.1);
padding: 4rem 1.5rem;
&Payment {
text-align: center;
width: 100px;
border: 1px solid #1e88e5;
border-radius: 3px;
padding: .6rem 0;
line-height: 1;
&_bank {
&-img {
background: url('../img/general/bank_creditCard.svg') no-repeat;
width: 18px;
height: 16px;
}
}
&_paypal {
&-img {
background: url('../img/general/bank_paypal.svg') no-repeat;
width: 18px;
height: 16px;
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question