SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
Metodika BEM 
Martin Pešout / @martinpesout / martinpesout.cz
Co je to BEM? 
CO + PROČ + JAK
Milníkem byl 2013 
• 2013 
• boom responsivního designu (RWD) 
• RWD také znamená více složitějších CSS stylů
Milníkem byl 2013 
• 2013 
• boom responsivního designu (RWD) 
• RWD také znamená více složitějších CSS stylů 
• 2014 
• boom optimalizací vytvořených responsivních webů 
• responsivní web neznamená rychlý web na 
mobilních připojeních
Vývoj webů v roce 2014 
potřebuje metodologii 
Skutečně potřebujeme dobrá pravidla 
… raději než další frameworky
Proč vzniknul BEM? 
• Způsob jak orgranizovat kód pro celý tým na 
velkých projektech 
• Znovupoužitelné komponenty 
• Komponenty s dlouhou životností 
• Snadno se osvojuje pro nové členy v týmu
Nejde o magii 
BEM není těžké se naučit. 
Na webu také na toto téma 
najdeme celou řadu článků 
a ukázek.
Nepoužívejte #ID selektory!
BEM = block + element 
+ modifier
Block 
• Oddělené komponenty 
• button 
• menu 
• heading
Block 
• Oddělené komponenty 
• button 
• menu 
• heading 
• Znovupoužitelné 
• Nezávislé na dalších stylech
Element 
• Vnitřní součást blocku 
• button 
• menu 
• heading
Element 
• Vnitřní součást blocku 
• button - icon 
• menu - item 
• heading - logo
Element 
• Vnitřní součást blocku 
• button - icon 
• menu - item 
• heading - logo 
• Nemá význam pokud by byl použit odděleně 
• Některé bloky se nemusí nutně dělit na elementy
Modifier 
• Definuje stav blocku nebo elementu 
• button 
• menu - item 
• heading
Modifier 
• Definuje stav blocku nebo elementu 
• button - color 
• menu - item - active state 
• heading - level
BEM používá třídy jako 
selectory pro bloky, 
elementy a modifikátory
Konvence pro pojmenování 
block 
btn 
menu 
heading
Konvence pro pojmenování 
block__element 
btn__icon 
menu__item 
heading__logo
Konvence pro pojmenování 
block__element––modifier 
btn––large 
btn__icon––arrow 
menu––secondary 
menu__item––active
Hlavička 
<div class="header header--main"> 
<h1 class=“header__title">Brian &amp; Jessica</h1> 
<div class=“header__description”> 
Main information about our wedding 
</div> 
</div>
Obvyklé chyby 
<div class="header header--main"> 
<h1>Brian &amp; Jessica</h1> 
<p> 
Main information about our wedding 
</p> 
</div> 
• Nepoužívejte sdílené styly 
• Nepoužívejte globální definice stylů (pouze 
normalize.css je povolen) 
• Žádné definice vně bloku
Tlačítko 
<a href="#love-story" class="action-btn action-btn–– 
arrow-down”></a>
Banner 
<div class=“banner"> 
<img src="/images/main-banner-large.jpg" alt="Bride 
and groom” class="banner__img"> 
<div class="banner__title">Soon together</div> 
<a href="#love-story" class="banner__btn action-btn 
action-btn--arrow-down"></a> 
</div>
Banner 
<div class=“banner"> 
<img src="/images/main-banner-large.jpg" alt="Bride 
and groom” class="banner__img"> 
<div class="banner__title">Soon together</div> 
<a href="#love-story" class="banner__btn action-btn 
action-btn--arrow-down"></a> 
</div> 
• Můžeme kombinovat více bloků dohromady
Nezávislé styly 
• Můžeme změnit HTML syntax a vždy dosáhneme 
stejného vzhledu 
<ul class=“menu”> 
<li class=“menu__item”>Home</li> 
<li class=“menu__item menu__item––active”>Contact</li> 
</ul> 
<div class=“menu”> 
<div class=“menu__item”>Home</div> 
<div class=“menu__item menu__item––active”>Contact</div> 
</div>
Tipy a triky 
• Preprocessor vám může pomoci k lepší 
organizaci stylů do více souborů. Každý blok 
může mít vlastní soubor. 
• Použijte prefix js- pro třídy nebo ID selectory 
elementů, na které se odkazujete v 
JavaScriptových souborech
Děkuju za 
pozornost 
Martin Pešout / @martinpesout / martinpesout.cz

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Metodika BEM

  • 1. Metodika BEM Martin Pešout / @martinpesout / martinpesout.cz
  • 2. Co je to BEM? CO + PROČ + JAK
  • 3. Milníkem byl 2013 • 2013 • boom responsivního designu (RWD) • RWD také znamená více složitějších CSS stylů
  • 4. Milníkem byl 2013 • 2013 • boom responsivního designu (RWD) • RWD také znamená více složitějších CSS stylů • 2014 • boom optimalizací vytvořených responsivních webů • responsivní web neznamená rychlý web na mobilních připojeních
  • 5. Vývoj webů v roce 2014 potřebuje metodologii Skutečně potřebujeme dobrá pravidla … raději než další frameworky
  • 6. Proč vzniknul BEM? • Způsob jak orgranizovat kód pro celý tým na velkých projektech • Znovupoužitelné komponenty • Komponenty s dlouhou životností • Snadno se osvojuje pro nové členy v týmu
  • 7. Nejde o magii BEM není těžké se naučit. Na webu také na toto téma najdeme celou řadu článků a ukázek.
  • 9. BEM = block + element + modifier
  • 10. Block • Oddělené komponenty • button • menu • heading
  • 11. Block • Oddělené komponenty • button • menu • heading • Znovupoužitelné • Nezávislé na dalších stylech
  • 12. Element • Vnitřní součást blocku • button • menu • heading
  • 13. Element • Vnitřní součást blocku • button - icon • menu - item • heading - logo
  • 14. Element • Vnitřní součást blocku • button - icon • menu - item • heading - logo • Nemá význam pokud by byl použit odděleně • Některé bloky se nemusí nutně dělit na elementy
  • 15. Modifier • Definuje stav blocku nebo elementu • button • menu - item • heading
  • 16. Modifier • Definuje stav blocku nebo elementu • button - color • menu - item - active state • heading - level
  • 17. BEM používá třídy jako selectory pro bloky, elementy a modifikátory
  • 18. Konvence pro pojmenování block btn menu heading
  • 19. Konvence pro pojmenování block__element btn__icon menu__item heading__logo
  • 20. Konvence pro pojmenování block__element––modifier btn––large btn__icon––arrow menu––secondary menu__item––active
  • 21.
  • 22. Hlavička <div class="header header--main"> <h1 class=“header__title">Brian &amp; Jessica</h1> <div class=“header__description”> Main information about our wedding </div> </div>
  • 23. Obvyklé chyby <div class="header header--main"> <h1>Brian &amp; Jessica</h1> <p> Main information about our wedding </p> </div> • Nepoužívejte sdílené styly • Nepoužívejte globální definice stylů (pouze normalize.css je povolen) • Žádné definice vně bloku
  • 24.
  • 25. Tlačítko <a href="#love-story" class="action-btn action-btn–– arrow-down”></a>
  • 26. Banner <div class=“banner"> <img src="/images/main-banner-large.jpg" alt="Bride and groom” class="banner__img"> <div class="banner__title">Soon together</div> <a href="#love-story" class="banner__btn action-btn action-btn--arrow-down"></a> </div>
  • 27. Banner <div class=“banner"> <img src="/images/main-banner-large.jpg" alt="Bride and groom” class="banner__img"> <div class="banner__title">Soon together</div> <a href="#love-story" class="banner__btn action-btn action-btn--arrow-down"></a> </div> • Můžeme kombinovat více bloků dohromady
  • 28. Nezávislé styly • Můžeme změnit HTML syntax a vždy dosáhneme stejného vzhledu <ul class=“menu”> <li class=“menu__item”>Home</li> <li class=“menu__item menu__item––active”>Contact</li> </ul> <div class=“menu”> <div class=“menu__item”>Home</div> <div class=“menu__item menu__item––active”>Contact</div> </div>
  • 29. Tipy a triky • Preprocessor vám může pomoci k lepší organizaci stylů do více souborů. Každý blok může mít vlastní soubor. • Použijte prefix js- pro třídy nebo ID selectory elementů, na které se odkazujete v JavaScriptových souborech
  • 30. Děkuju za pozornost Martin Pešout / @martinpesout / martinpesout.cz