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
Introduction to CSS Architecture
Search
Masaaki Morishita
June 04, 2015
Programming
400
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to CSS Architecture
新卒社内勉強会(2015/6/4) の資料です
Masaaki Morishita
June 04, 2015
More Decks by Masaaki Morishita
See All by Masaaki Morishita
PostCSS: Build your own CSS processor
morishitter
6
4.8k
Houdini: Abracadabra CSS
morishitter
1
890
Modern CSS: architecture, future specs and build flow
morishitter
13
2.7k
PostCSS and cssnext
morishitter
11
1.8k
PostCSS 5.0: for Custom CSS Preprocessing
morishitter
10
1.2k
PostCSS for beginners
morishitter
6
1.5k
CSSfmt
morishitter
2
280
Introduction to PostCSS
morishitter
6
1.8k
Yet Another CSS Preprocessor
morishitter
1
5.6k
Other Decks in Programming
See All in Programming
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
190
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.7k
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
490
Claude Team Plan導入・ガイド
tk3fftk
0
210
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
270
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
510
コーディングルールの鮮度を保ちたい for SRE NEXT 2026 / keep-fresh-go-internal-conventions-sre-next-2026
handlename
0
140
えっ!!コードを読まずに開発を!?
hananouchi
0
220
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
3
1.6k
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
260
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
320
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
570
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.1k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Ethics towards AI in product and experience design
skipperchong
2
330
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
180
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Become a Pro
speakerdeck
PRO
31
6k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
How to make the Groovebox
asonas
2
2.3k
Producing Creativity
orderedlist
PRO
348
40k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Transcript
Introduction to CSS Architecture in ৽ଔࣾษڧձ
ࣗݾհ • Twitter: @morishitter_ • GitHub: morishitter • εϓϥτΡʔϯ: ϥϯΫ20
• χϯςϯυʔωοτϫʔΫID: CSS0830
࣍ • CSSͷ • طଘͷCSSઃܭख๏ • CSSઃܭͷຊ࣭
CSSͷ
CSS is γϯϓϧ article h1 { font-size: 20px; padding-bottom: 5px;
border-bottom: solid 1px #ccc; margin-bottom: 10px; }
γϯϓϧ ≒ ؆୯
article h1 { font-size: 20px; padding-bottom: 5px; border-bottom: solid 1px
#ccc; margin-bottom: 10px; } article h1 + p.lead { font-size: 14px; color: #ddd; line-height: 1.5; }
article h1 { font-size: 20px; padding-bottom: 5px; border-bottom: solid 1px
#ccc; margin-bottom: 10px; } article h1 + p.lead { font-size: 14px; color: #ddd; line-height: 1.5; } #header { }
article h1 { font-size: 20px; padding-bottom: 5px; border-bottom: solid 1px
#ccc; margin-bottom: 10px; } article h1 + p.lead { font-size: 14px; color: #ddd; line-height: 1.5; } #header { } #header > img#logo{ } ul > list.item { } .menu { } .menu .nav { } #sidebar { } #sidebar .widget { }
#header { } #header > img#logo{ } ul > list.item
{ } #menu { } #menu .nav { } #sidebar { } #sidebar .widget { } body { } .container{ } .container > h2.title { } .col-md-5 { } .row .col-md-5 { } .landing > h1 { } .widget .title { } #sidebar > img#logo{ } ul > list#logo { } #article { } #article .title { } footer small { } footer small .info { }
!important;
ϧʔϧηοτͷӨڹൣғ͕ Θ͔Βͳ͘ͳΔ
؆୯ ≒ յΕ͍͢
CSSͷʢٕज़తଆ໘ʣ • ߏจ͕ශऑ • ϧʔϧηοτʹείʔϓ͕ͳ͍ • શͯͷϧʔϧηοτ͕άϩʔόϧఆٛ
CSSͷʢӡ༻తଆ໘ʣ • σβΠϯ͕มΘΒͳ͍WebαΠτͳ͍ • ͨΓతͳमਖ਼͕܁Γฦ͞ΕΔ
CSSͷʢࣾձతଆ໘ʣ • CSSᢞΊΒΕ͗͢ • ϓϩάϥϚʹόΧʹ͞ΕɺσβΠφʔ͕ࡶʹॻ͘ • ยखؒCSS • ίʔυͷైḤͳཧ
CSS ͨͩWebͷϏδϡΞϧσβΠϯ ΛදݱͰ͖Ε͍͍ͷͰͳ͍
WebαΠτΞʔτͰͳ͘ ใγεςϜ
CSS ιϑτΣΞͷҰ෦ͱͯ͠ อक͞ΕΔ͖ͩ͠ ϦϑΝΫλϦϯάͷର
CSS ͪΌΜͱॻ͜͏ͳ
طଘͷCSSઃܭख๏
طଘͷCSSઃܭख๏ • OOCSS • SMACSS • BEM
OOCSS
OOCSS • Object Oriented CSS (by Nicole Sullivan) • ʮߏͱݟͨͷʯ
• ʮίϯςφͱίϯςϯπͷʯ • CSSઃܭͷϕʔεͱͳΔ֓೦ • ଟ͘ͷCSSϑϨʔϜϫʔΫͰ࠾༻
OOCSS WebϖʔδΛϨΰͷΑ͏ʹߟ͑Δ
OOCSS .btn { property: value; } /* Decoration */ .btn-danger
{ } .btn-success { } /* Layout */ .btn-large { } .btn-small { }
OOCSS <button class="btn btn-success btn-large">Submit</button>
OOCSS <button class="btn btn-success btn-large">Submit</button> <button class="btn btn-danger btn-large">Delete</button>
SMACSS
SMACSS • Scalable and Modular Architecture for CSS • ϕʔεOOCSS
• OOCSS + ໋໊نଇ Έ͍ͨͳͷ
SMACSS • CSS ͷΧςΰϥΠζ • Base • Layout • Module
• State • Theme
Base • ཁૉͦͷͷͷσϑΥϧτͷελΠϧ • CSSϦηοτ͕͜Ε body { background: white; }
p { margin-bottom: .5rem; }
Layout • ϖʔδΛΤϦΞ͝ͱʹׂ .l-header { margin-bottom: 20px; } .l-footer {
border-top: 1px solid gray; } .l-main { float: left; width: 80%; }
Module • ࠶ར༻Մೳͳύʔπ • ModuleLayoutͷதʹஔ͞ΕΔ • ผͷLayoutͰ࠶ར༻Ͱ͖ΔΑ͏ʹશʹ ಠཱ
Module <div class="item"> <h2 class="item-title"></h2> <p class="item-text"></p> <div class="item-image"><img src="..."
alt=""></div> <div class="item-price"></div> </div>
State • LayoutModuleͷಛఆͷঢ়ଶΛද͢ .is-hidden { display: none; } .is-error {
color: red; }
Theme • ίϯϙʔωϯτͷ০ .theme-border { border-color: #ccc; } .theme-background {
background-color: #eee; }
BEM
BEM • Block, Element, Modifier • Yandex
BEM (Block) • ̍ͭͷίϯϙʔωϯτͷ·ͱ·Γ
Element (BEM) • BlockΛߏ͢Δཁૉ • ΞϯμʔείΞ2ͭ (__) Λ͏͜ͱ͕ଟ͍ • Block__Element
BEM (Modifier) • Block ·ͨ ElementͷόϦΤʔγϣϯ • SMACSSͰ͍͏StateͱTheme • ϋΠϑϯ2ͭ
(--) Λ͏͜ͱ͕ଟ͍ (MindBEMding) • Block—Modifier, Element--Modifier
BEM <ul class="tab" role="tablist"> <li class="tab__item"></li> <li class="tab__item"></li> <li class="tab__item--selected"></li>
<li class="tab__item"></li> </ul>
ͦͷଞ • ACSS • MCSS • FLOCSS
Web੍࡞ऀͷͨΊͷ CSSઃܭͷڭՊॻ
ཁ͢Δʹ
CSSͷϧʔϧηοτʹ είʔϓ͕ͳ͍͔Β໋໊نଇ ͰͳΜͱ͔͠Α͏
CSSઃܭͷຊ࣭
ϚϧνΫϥε ͱ γϯάϧΫϥε • ϚϧνΫϥεઃܭɿHTMLͷclassଐੑʹෳͷ ΛΈ߹ΘͤͯελΠϧΛͯΔ (OOCSS) • γϯάϧΫϥεઃܭɿHTMLͷclassଐੑʹ1ͭͷ ͰελΠϧΛͯΔ
(BEM)
ϚϧνΫϥεઃܭ <button class="btn btn-success btn-large">Submit</button>
ϚϧνΫϥεઃܭͷϝϦοτ • ϧʔϧηοτͷ࠶ར༻ • Ͱͳ͘ͳΓϑΝΠϧαΠζ͕খ͘͞ͳΔ
ϚϧνΫϥεઃܭͷ • ϧʔϧηοτʹڞ௨͢ΔϓϩύςΟ͕͋ͬͨ Β্ॻ͖͞ΕΔ • ϧʔϧηοτؒʹ҉ͷґଘ͕ؔͰ͖Δ • ް͍ελΠϧΨΠυ͕ඞཁ • HTMLͷηϚϯςΟοΫεΛଛͶΔ
γϯάϧΫϥεઃܭ <button class=“btn-submit”>Submit</button> <button class=“btn-submit">Submit</button>
γϯάϧΫϥεઃܭͷϝϦοτ • 1classଐੑʹରͯ͠1ϧʔϧηοτͳͷͰγϯ ϓϧ • ίϯςϯπͷ༰ʹదͨ͠ηϚϯςΟοΫͳ ໊લ
γϯάϧΫϥεઃܭͷ • 1ͭͷϧʔϧηοτ͕େ͖͘ͳΓɺهड़͕ ʹͳΔ • ϧʔϧηοτͷ࠶ར༻ੑ͕͍ • ϑΝΠϧαΠζͷංେԽ • αΠτύϑΥʔϚϯεͷԼ
γϯάϧΫϥεઃܭͱ ϚϧνΫϥεઃܭͷ ͍͍ͱ͜औΓΛͨ͠ ͍͖͞ΐ͏ͷઃܭख๏ by @morishitter_
CSSઃܭͷຊ࣭
ηϨΫλͷ໋໊نଇͰͳ͘
ϧʔϧηοτͷׂཻ
ཧతͳ CSS ͱԿ͔
CSS ʹݶͬͨͰͳ͍
ࠓ͕͍ࣗͬͯΔٕज़ɾಓ۩ ࣗʹͱͬͯҰମͲ͏͍͏ଘࡏͳͷ͔
࣌ʹͦͷٕज़ͷࢥ͍͑ٙ͞ ΑΓྑ͍ͷΛ࡞Γ͍ͨ
ಓ۩ʹৼΓճ͞ΕΔͳ ղܾ͍͍ͨͭ͠ಉ͡
શମΛ၆ᛌ͠ ຊ࣭ΛݟۃΊΔ
Thanks :D Any Questions? @morishitter_