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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
880
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
270
Introduction to PostCSS
morishitter
6
1.8k
Yet Another CSS Preprocessor
morishitter
1
5.5k
Other Decks in Programming
See All in Programming
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
240
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4k
さぁV100、メモリをお食べ・・・
nilpe
0
140
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
230
JavaDoc 再入門
nagise
0
320
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
880
net-httpのHTTP/2対応について
naruse
0
470
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
190
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
260
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
210k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Crafting Experiences
bethany
1
170
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
For a Future-Friendly Web
brad_frost
183
10k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
210
Utilizing Notion as your number one productivity tool
mfonobong
4
320
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Bash Introduction
62gerente
615
220k
Side Projects
sachag
455
43k
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_