Open genkio opened 7 years ago
study notes taken from the frontendmasters Scalable Modular Architecture for CSS course.
knowledge I obtained in this course + blended with my own take = Less SMACSS starter
What is SMACSS?
Base
html { font-family: Arial, Helvetica, sans-serif; font-size: 14px; } body { margin: 0; padding: 0; } h1, h2, h3 { margin: 1em 0; }
Layout
.l-highlight { background-color: #CCC; } .l-featured { background-color: #CCC; } .l-constrained { width: 760px; } .l-content { float: right; width: 20%; } .l-sidebar { float: right; width: 80%; }
<div> <div class="layout-constrained"></div> </div> <div class="layout-highlight"> <div class="layout-constrained"></div> </div>
Module
btn-clean
modal-header
Sub-module
Sub-component
-
.module-name {} /*allows for hyphens, always a root node*/ .module-name--submodule {} /*hyphens*/ .module-name__subcomponent {} /*underscores*/ /*or*/ .moduleName {} .moduleName-subModule {} .moduleName--subComponent {}
State
is-
.btn {} .btn-is-active {} .btn-is-disabled {}
Theme
.theme-header {} .theme-border {} .theme-background {}
Helpers
.text-xl { font-size: 140%; } .text-l { font-size: 120%; } .text {} .text-s { font-size: 90%; } .text-xs { font-size: 80%; }
Prefixing for versioning
.next-btn {} .next-btn-is-active {} .next-btn-is-disabled {}
Wrap up
class
id
!important
knowledge I obtained in this course + blended with my own take = Less SMACSS starter
What is SMACSS?
SMACSS is Categorization
Base
Layout
Module
btn-clean
should not be relying on styles coming frommodal-header
Sub-module
Sub-component
SMACSS is Naming Convention
Module
-
State
is-
is-
prefix indicates likelihood of JavaScript dependencyis-
indicates a toggleable stateTheme
Helpers
Prefixing for versioning
Wrap up
SMACSS is Decoupling CSS from HTML
Some other conventions
class
overid
!important
except states