Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CSS_重構.pdf
Search
CypressKuo
January 28, 2021
Technology
30
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSS_重構.pdf
CypressKuo
January 28, 2021
More Decks by CypressKuo
See All by CypressKuo
Deep-copying.pdf
cypresskuo
0
42
CSS_for_Web_Vitals.pdf
cypresskuo
0
48
談談_Code_review.pdf
cypresskuo
0
56
REST_vs_GraphQL_今夜はご注文はどっち.pdf
cypresskuo
0
30
跟上_JS_的腳步-ES2020.pdf
cypresskuo
0
39
Core_Web_Vitals.pdf
cypresskuo
0
62
這個時代人人都知道的敏捷開發.pdf
cypresskuo
0
81
Webassembly.pdf
cypresskuo
0
21
談談_Functional_Programming.pdf
cypresskuo
0
33
Other Decks in Technology
See All in Technology
今さら理解するウェブフォントver.2026
takanorip
3
840
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
140
TinyGoでオブザーバビリティ?OpenTelemetryはTinyGoで使えるのか / Is OpenTelemetry available in TinyGo environment?
ymotongpoo
2
140
Metadata - Section 1: HTML Basics
mohab1
0
120
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
170
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
120
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.3k
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
440
go-sqletch
moznion
0
140
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
950
Refining Active Record
shugo
0
160
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Building AI with AI
inesmontani
PRO
1
1.3k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
WCS-LA-2024
lcolladotor
0
890
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Fireside Chat
paigeccino
43
4.1k
We Have a Design System, Now What?
morganepeng
55
8.4k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
480
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
Transcript
CSS 重構 架構完善的樣式表
CSS Refactoring CSS重構 作者: Steve Lindstrom 譯者: 陳健文 出版社:歐萊禮 出版日期:2017/04/25
Agenda 1. 重構與架構 2. 串接 3. Good CSS 4. 正規化
5. 測試 6. 重構策略
重構與架構 重構:讓簡化程式、好複用、不改變其行為 軟體架構:描述軟體專案中,各種零件如何組織的用語
好架構 可預期 有助複用 易擴充 好維護
重構 誰需要:還活著的程式碼 誰不需要:沒有新需求、死掉的程式碼 何時:發現異味
重構與架構 簡單的說,重構能改善軟體的架構。
串接 決定樣式如何套用到元素上的方法 (其實就是 CSS 的權重
None
Good CSS 善用註解 一致的結構 (coding style) 單純的選取器 切斷 CSS 與
JS 的耦合 使用類別選取器 取有意義的名稱 避免過度模組化(? 使用對的 box model
正規化 (略 都 2021 年了,就善用別人寫好的。 把精力留在其他地方 reset.css normalize.css
測試 測試 CSS 難度高 瀏覽器多 視窗尺寸 自動化困難
測試 只測重要的瀏覽器 有彈性的設計 使用視覺回歸測試 ex: Gemini (https://github.com/gemini-testing/gemini) 遵守 Style Guide
重構策略 使用工具分析 CSS Dig (https://www.cssdig.com) 大家的好朋友: chrome dev tool
重構策略 一致性的架構規則 (coding style) 刪除廢碼 切斷 CSS 與 JS 的耦合
拆分基底樣式、拆分工具樣式 移除多餘的 ID、將 ID 轉為類別 定義可複用組件 移除行內 CSS 隔離針對性的 CSS (ex IE only or Safari only)
成效評估 沒改壞 降低耦合 減少檔案大小 省下開發時間
同場加映 OOCSS SMACSS BEM CSS Modules CSS in JS
重構過程很繁雜,但結果會讓人身心愉快,就像減肥一樣
感謝聆聽 Q & A