A
A
Alibek Kulseitov2017-12-18 22:53:55
css
Alibek Kulseitov, 2017-12-18 22:53:55

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

3 answer(s)
L
Leonid Knyazev, 2017-12-18
@amorphis

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.

D
Dima Polos, 2017-12-18
@dimovich85

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
}
}

A
Andrew Ghostuhin, 2017-12-19
@Torin_Asakura

.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;
            }
        }
    }
}

PS: I do not advise you to put svg as a background

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question