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

CSS 不是我們想像的這麼簡單! [台北場]

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Kuro Hsu Kuro Hsu
June 05, 2019

CSS 不是我們想像的這麼簡單! [台北場]

v-tw meetup #1 2019/06/05

活動錄影: https://www.youtube.com/watch?v=dtX51ru_eXU

Avatar for Kuro Hsu

Kuro Hsu

June 05, 2019

More Decks by Kuro Hsu

Other Decks in Education

Transcript

  1. 良好的 CSS 架構 • 可預測性 - Predictable • 可重複使⽤用 -

    Reusable • 容易易維護 - Maintainable • 可擴充性 - Scalable
  2. 將結構分類 • Base - CSS Reset / CSS Normalize /

    global styles… • Layout - header / footer / content / sidebar … • Module - list / button / components … • State - active / error / hidden … • Theme
  3. .box, .box h2, .box ul, .box p { … }

    .box, .box .header, .box .body { … }
  4. .box, .box h2, .box ul, .box p { … }

    .box, .box .header, .box .body { … } .box, .box-header, .box-body { … }
  5. .block { ... } .block--modifier { ... } .block__element {

    ... } .block__element--modifier { ... }
  6. Thinking in Atomic • 變化是可被預測的 - Changes are predictable •

    作⽤用範圍有限 - Scope is limited • 精簡的 CSS - CSS is lean • 與元件解耦 - Components are portable • 初學者易易上⼿手 - Beginner-friendly
  7. • CSS Modules,透過 webpack 編譯 • 各種 CSS in JS

    解決⽅方案 ( React ) • 寫在 .vue file 中的 scoped CSS • Angular 裝飾⼦子的 CSS • 現代的關注點分離 - 從功能到元件