Upgrade to Pro — share decks privately, control downloads, hide ads and more …

BEM // Get Started // SASS Guidelines

BEM // Get Started // SASS Guidelines

Intro to BEM. SASS Guidelines.

Avatar for Julia Rechkunova

Julia Rechkunova

September 10, 2016
Tweet

Other Decks in Programming

Transcript

  1. BEM // Block inside Element <section class="search"> <div class="search__content"> <input

    type="text" class="search__input"> <button class="button">Search</button> </div> ... </section>
  2. BEM // Element for additional styles (margins, ...) <section class="search">

    <div class="search__content"> <input type="text" class="search__input"> <button class="button" style="margin-left: 30px">Search</button> </div> ... </section>
  3. BEM // Element for additional styles (margins, ...) <section class="search">

    <div class="search__content"> <input type="text" class="search__input"> <div class="search__button"> <button class="button">Search</button> </div> </div> </section>
  4. BEM // Modifier <section class="search"> <div class="search__content"> <input type="text" class="search__input">

    <div class="search__button"> <button class="button button--small">Search</button> </div> </div> </section>
  5. BEM // Modifier name + value <section class="search"> <div class="search__content">

    <input type="text" class="search__input"> <div class="search__button"> <button class="button button--size-small">Search</button> </div> </div> </section>
  6. BEM with CSS Block .block { … } Element .block__element

    { … } Modifier .block--modifier { … } .block__element--modifier { … }
  7. BEM with SASS .block { &--modifier { … } }

    .block__element { … } // searchable
  8. BEM with SASS .block { &--modifier { … } }

    .block__element { … } @include media($mq) { … // same structure here }
  9. BEM with SASS .block { ... &:hover { … }

    &:before { … } &--modifier { … } } .block__element { … } .block__long-element-name-here { … }
  10. SASS Code Style • Always use .class selectors • No

    #id as a selector • No tag as a selector • Max 2 levels for nesting • .util-text-overflow-break • .layout-page • 0, not 0px • #ccc, not #cccccc or #CCC • … More info https://sass-guidelin.es/
  11. CSS properties order .selector { /* Positioning */ /* Display

    & Box Model */ /* Color */ /* Text */ /* Other */ } More info https://css-tricks.com/poll-results-how-do-you-order-your-css-properties/