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
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
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
210
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
160
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
180
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
340
Webの地図
yosuke_furukawa
PRO
3
2.4k
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
130
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
640
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
210
ソフトウェアラスタライザ
fadis
1
800
フロントエンドUIフレームワークのこれまでとこれから
ssssota
1
860
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
130
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
GraphQLとの向き合い方2022年版
quramy
50
15k
How GitHub (no longer) Works
holman
316
150k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
490
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
660
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Designing for Performance
lara
611
70k
The browser strikes back
jonoalderson
0
1.6k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
A Soul's Torment
seathinner
7
3.6k
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_