getbem.github.io icon indicating copy to clipboard operation
getbem.github.io copied to clipboard

How to avoid code duplication?

Open asbpp opened this issue 8 years ago • 1 comments

I have two set of same representative code due to block and I feel it's duplicate. How can avoid duplicate CSS code as well having different block elements? An example would be very much helpful.

asbpp avatar Mar 22 '17 21:03 asbpp

You may use mixes:

<div class="my-block">
    <div class="my-block__elem1 my-block__common"></div>
    <div class="my-block__elem2 my-block__common"></div>
</div>

For more info about mixes see https://en.bem.info/methodology/css/#mixes

tadatuta avatar Mar 22 '17 22:03 tadatuta