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
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
140
速習iPhone Duo対応
yuukiw00w
2
980
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
960
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
sbt 2.0: takeoff
eed3si9n
0
120
Jetpack Compose Mechanisms
skydoves
2
700
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
360
ジョジョの世界をXRで再現する
mofurune
0
150
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
140
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
160
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Un-Boring Meetings
codingconduct
0
450
Google's AI Overviews - The New Search
badams
0
1.6k
It's Worth the Effort
3n
188
29k
How to Talk to Developers About Accessibility
jct
2
570
Utilizing Notion as your number one productivity tool
mfonobong
4
610
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
260
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
310
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
260
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
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_