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命名及书写规范
Search
hugo
October 12, 2014
Programming
700
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.4k
html5 新技术
baofen14787
3
190
html5 新技术 2
baofen14787
1
150
html5 新技术 3
baofen14787
1
120
Other Decks in Programming
See All in Programming
WebAssembly in Android Apps 〜 WASMはJNIの夢を見るか
keiji
1
110
Intent as Code
shoppingjaws
6
1k
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
170
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
420
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3k
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
560
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
240
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
130
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.7k
一人だけ、Kiroが静止する日
hideg
0
110
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
110
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
300
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
432
67k
Unsuck your backbone
ammeep
672
58k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Crafting Experiences
bethany
1
340
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
Fireside Chat
paigeccino
43
4k
HDC tutorial
michielstock
2
870
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
A Tale of Four Properties
chriscoyier
163
24k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
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! “祖宗姓张,其⼦子孙都姓张”