Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CSS命名及书写规范
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
hugo
October 12, 2014
Programming
690
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSS命名及书写规范
CSS命名及书写规范
hugo
October 12, 2014
More Decks by hugo
See All by hugo
移动端性能调优及16ms优化
baofen14787
1
2.3k
html5 新技术
baofen14787
3
190
html5 新技术 2
baofen14787
1
150
html5 新技术 3
baofen14787
1
110
Other Decks in Programming
See All in Programming
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
600
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
190
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
130
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
790
1B+ /day規模のログを管理する技術
broadleaf
0
120
ふつうのFeature Flag実践入門
irof
8
4.2k
Webフレームワークの ベンチマークについて
yusukebe
0
180
Vite+ Unified Toolchain for the Web
naokihaba
0
360
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.4k
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
370
Featured
See All Featured
Speed Design
sergeychernyshev
33
1.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
Embracing the Ebb and Flow
colly
88
5.1k
The Pragmatic Product Professional
lauravandoore
37
7.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
The Curse of the Amulet
leimatthew05
2
13k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.6k
The untapped power of vector embeddings
frankvandijk
2
1.8k
Tell your own story through comics
letsgokoyo
1
980
Transcript
CSS命名及书写规范 宇果
⼤大纲 • CSS命名 • ⻚页⾯面层级
姓⽒氏命名法
在⼦子孙模块数量可预测的情况下,继承祖先模块的命名前缀
当⼦子孙模块数量较多,且⽆无法预估时,可以选择采⽤用继承“祖先+⽗父”模块的命名前缀,! 以保证模块之间的独⽴立性
⼦子模块中,可以嵌套其他模块,可理解为“娶了媳妇、嫁了郎”
公共模块和独⽴立模块 • 同⼀一个⻚页⾯面出现2次以上同⼀一个类名 • 2个以上的⻚页⾯面出现同⼀一个类名 1、全站公共模块以“mod-”开头 2、频道及⻚页⾯面公共模块以“xx-mod-”开头,(xx为频道名或⻚页⾯面名缩写) 3、独⽴立模块,命名为⼀一个简短的单词,如“hot、floor、banner”等 如何区分公共模块与独⽴立模块
Q:为什么要⽤用这种⽅方式 • CSS以单层命名为主,嵌套⼀一般不会超过3层,提升CSS解析效率。 • 团队⻛风格统⼀一,可⾼高效的迭代、维护。同时不再担⼼心命名冲突、css是否可删等问 题。 • 减少命名烦恼,统⼀一继承模块组件命名,⼦子元素可⾃自由使⽤用常⽤用类名,如:xxx- name,xxx-item,xxx-cnt
⻚页⾯面层级
⻚页⾯面结构层 布局层 模块区域
⻚页⾯面结构层 ⼯工具条 c-toolbar 头部 c-header 主体内容 c-content 指引信息|快速⼊入⼝口 c-footer 版权
c-subfooter ⻚页⾯面结构层: 类名以频道或站点名称缩写开头
布局层 ⼀一列 gird-c1 两列 gird-c2a gird-c2b 三列 gird-c3a gird-c3b gird-c3c
布局层: 类名以gird开头 c1:1列,c2:2列,c3:3列 a:第1列,b:第2列,c:第3列
模块区域 说明: hd、ft不⼀一定存在,但存在其中⼀一个时, 必然要存在bd 模块基本结构
完!Thanks! “祖宗姓张,其⼦子孙都姓张”