Skip to content

Instantly share code, notes, and snippets.

@coltborg
Last active February 27, 2019 02:50
Show Gist options
  • Save coltborg/64d26c9149a39fc1fe3c5adb2257145e to your computer and use it in GitHub Desktop.
Save coltborg/64d26c9149a39fc1fe3c5adb2257145e to your computer and use it in GitHub Desktop.
CSS leason for box model & specificity.

CSS Basics


Agenda

  • Basics
  • The Cascade
  • Specificity
  • Box Model
  • Layout
  • Naming Conventions

Basics


选择 (Selector)

/* 👇 This is the selector */
.red {
  color: red;
}

属性 (Property)

.red {
  color: red;
/* 👆 this is the property. */
}

值 (Value)

.red {
  color: red;
      /* 👆 this is the value. */
}

Selector Example


级联 (Cascade)

CSS stands for Cascading Style Sheets.

The "Cascade" in CSS applies rules from top to bottom.


黄果树瀑布 (Huangguoshu Waterfall)

Huangguoshu Waterfall


Cascade Example


特异性 (Specificity)

Specificity determines, which rule is applied by the browsers.


Specificity is usually the reason why your CSS-rules don’t apply to some elements, although you think they should.


If two selectors apply to the same element, the one with higher specificity wins.


SpeciFISHity


Specifishity part 1


Specifishity part 2


Specifishity part 3


Specifishity part 4


Specifishity part 5


计算器 (Specificity Calculator)

Specificity Calculator

specificity.keegan.st


Box Model

Box Model Example showing content, padding, border, and margin.


Notebook is the content.

Bubblewrap is the padding.

Bag is the border.

Space between bag to other bag is margin.


Conventions


BEM

BEM 101

CSS Tricks - BEM 101

BEM Example - CodePen

BEM Example


Functional / Atomic

Functional 101

Functional Example - CodePen

Functional Example


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment