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
BEM - Los problemas de CSS y cómo se pueden aliviar
Search
Guillermo Moreno
February 23, 2017
Programming
0
78
BEM - Los problemas de CSS y cómo se pueden aliviar
Presentación para Platanus en Febrero 2017
Guillermo Moreno
February 23, 2017
Tweet
Share
More Decks by Guillermo Moreno
See All by Guillermo Moreno
Desarrollo Móvil en Javascript: Cordova y React Native
gmq
0
120
Other Decks in Programming
See All in Programming
ゆるい個人開発のススメ
kuroppe1819
10
1k
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
560
2 週間で Twitter Bot を作ってみた
contour_gara
0
760
VS Code をプロダクトにどう取り込むか
onomax
1
640
Exploring the Implementation of “t.Run”, “t.Parallel”, and “t.Cleanup”
akarin
1
110
AmperとFleetを使ったAndroidアプリ
yoppie
0
250
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
420
CDKコントリビュートの最初の壁を越えよう! -簡単issueの見つけ方-
badmintoncryer
3
180
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
120
敵対的ポイフル
futabato
0
120
Goのエラースタックトレースの歴史と今後
sonatard
10
1.7k
Anthropic Cookbook のおすすめレシピ
schroneko
7
1.1k
Featured
See All Featured
Practical Orchestrator
shlominoach
183
9.7k
Visualization
eitanlees
137
14k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
Making Projects Easy
brettharned
109
5.5k
Designing for Performance
lara
602
67k
Embracing the Ebb and Flow
colly
80
4.2k
Debugging Ruby Performance
tmm1
70
11k
Fantastic passwords and where to find them - at NoRuKo
philnash
38
2.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
The Invisible Customer
myddelton
114
12k
Transcript
BEM BLOCK ELEMENT MODIFIER AKA: LOS PROBLEMAS DE CSS Y
CÓMO SE PUEDEN ALIVIAR
<div class="sidebar"> <h2>Secciones</h2> <ul> <li>Home</li> <li>Contacto</li> </ul> <h2>Sponsors</h2> <ul> <li>Platanus</li>
<li>Google</li> </ul> </div> .sidebar h2 { font-size: 1em; color: red; } .sidebar ul { list-style: none; } .sidebar ul li { font-size: .8em; } ¿PROBLEMAS EN CSS?
Secciones Home Contacto Sponsors Platanus Google
<div class="sidebar"> <h2>Secciones</h2> <ul> <li>Home</li> <li>Contacto</li> </ul> <h2 class="sponsors">Sponsors</h2> <ul
class="sponsors"> <li id="platanus">Platanus</li> <li>Google</li> </ul> </div> .sidebar h2 { font-size: 1em; color: red; } .sidebar ul { list-style: none; } .sidebar ul li { font-size: .8em; } .sidebar h2.sponsors { color: blue; } #platanus { color: yellow; text-decoration: underline; }
Secciones Home Contacto Sponsors Platanus Google
<div class="sidebar"> <h2>Secciones</h2> <ul> <li>Home</li> <li>Contacto</li> </ul> <h2 class="sponsors">Sponsors</h2> <ol
class="sponsors"> <li id="platanus">Platanus</li> <li>Google</li> </ol> </div>
Secciones Home Contacto Sponsors 1. Platanus 2. Google
ol { color: pink; } /* --- */ .sidebar h2
{ font-size: 1em; color: red; } .sidebar ul { list-style: none; } .sidebar ul li { font-size: .8em; } .sidebar h2.sponsors { color: blue; } #platanus {
<div class="sidebar"> <h2>Secciones</h2> <ul class="secciones"> <li>Home</li> <li id="platanus">Platanus</li> <li>Contacto</li> </ul>
<h2 class="sponsors">Sponsors</h2> <ol class="sponsors"> <li id="platanus">Platanus</li> <li>Google</li> </ol> </div> /* ... */ #platanus { color: yellow; text-decoration: underline; } .secciones * { text-decoration: none; }
Secciones Home Platanus Contacto Sponsors 1. Platanus 2. Google
Especi cidad. #platanus es mucho más especi co que .secciones
Fragilidad. el cambio de ul a ol rompió código que no debería haber roto Poco modular. El estilo de ol de otra parte de la página cambió el estilo de nuestra PROBLEMAS
BEM BLOCK * ELEMENT * MODIFIER
UN COMPONENTE O ENTIDAD QUE TIENE SIGNIFICADO POR SI MISMO
Y ES INDEPENDIENTE DEL RESTO BLOCK
PARTES DE UN BLOQUE QUE NO TIENEN SIGNIFICADO FUERA DE
ÉL. NOMBRE DE LA SECCIÓN + DOS GUIONES BAJOS. .sidebar__titulo .sidebar-section__link .btn__icon ELEMENT
IDENTIFICA CAMBIOS DE APARIENCIA O COMPORTAMIENTO EN UN ELEMENTO O
BLOQUE. NOMBRE DEL BLOQUE O ELEMENTO + DOS GUIONES. .sidebar__titulo--primary .sidebar-section__link--platanus MODIFIER
.sidebar__title { font-size: 1em; color: red; } .sidebar__list { list-style:
none; } .sidebar__item { font-size: .8em; } .sidebar__item--underline { text-decoration: underline; } .sidebar__title--sponsors { color: blue; } .sidebar__item--platanus { color: yellow; <div class="sidebar"> <h2 class="sidebar__title">Secciones</ <ul class="sidebar__list"> <li class="sidebar__item">Home</li> <li class="sidebar__item sidebar__item--platanus <li class="sidebar__item">Contacto</ </ul> <h2 class="sidebar__title--sponsors"> <ol> <li class=" sidebar__item sidebar__item--platanus sidebar__item--underline ">Platanus</li> <li class="sidebar__item">Google</li </ol> </div>