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
Introduction to CSS Architecture
Search
Masaaki Morishita
June 04, 2015
Programming
410
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
900
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
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.3k
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
500
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1k
iOSDC2026登壇資料.pdf
riofujimon
0
170
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
220
AHC070解法紹介
eijirou
0
130
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
7.6k
WebAssembly in Android Apps 〜 WASMはJNIの夢を見るか
keiji
1
110
What We Talk About When We Talk About XP
m_seki
2
660
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
140
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
360
JRuby: Past, Present, and Future
headius
0
160
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Discover your Explorer Soul
emna__ayadi
2
1.3k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
460
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Designing for humans not robots
tammielis
254
26k
Unsuck your backbone
ammeep
672
58k
First, design no harm
axbom
PRO
2
1.3k
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_