getbem.github.io
getbem.github.io copied to clipboard
How to avoid code duplication?
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.
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