On Github noudilus / bem-basic-presentation
Created by Arnoud van der Velden / @noudjes
A method to write reusable, scalable, maintainable & fast CSS code.
A way to write modular CSS
Forces to think about structure
Helps interpret a design quicker so you can start coding sooner
<div class="menu"> <div class="menu__item"></div> <div class="menu__item menu__item--active"></div> </div>
.menu { background: red; padding: 10px; } .menu__item { opacity: 0.5; margin: 10px; } .menu__item--active { margin: 20px; border: 1px solid blue; }
.menu { background: red; padding: 10px; &__item { opacity: 0.5; margin: 10px; } &__item--active { margin: 20px; border: 1px solid blue; } }
Independant reusable part of your interface
Contains elements and other blocks
Can contain one or more modifiers
Not to be confused with HTML blocksBelongs to a Block
Can contain blocks or other elements
Can contain one or more modifiers
A state different from the default
Can be applied to Block or Element
Most difficult part to understandOnly works with semantic HTML
Combine with other methods (OOCSS, SMACCS)
No deep nesting, keep small modules
How to use Modifier correctly on a block
How to apply Modifiers with LESS
Use @extend only if you are confident about the output
Something else..?