Тёмный

CSS BEM - The What, How, and Why | Block Element Modifier Methodology 

Closure: Web Dev. & More
Подписаться 1,3 тыс.
Просмотров 15 тыс.
50% 1

CSS code is messy. Actually, it gets messy over time, and only if you are not following a strict methodology. CSS BEM stands for Block Element Modifier and is a perfect example of a methodology that works!
CSS has many fundamental problems that result in code that is difficult to maintain and read. CSS is considered to be a mess and is hated by many developers. I was among these developers too, until I figured out the proper way to write CSS code. It takes some practice to learn BEM and chances are you won't like it at first, but as time goes, you will never want to move away from the Block, Element, and Modifier methodology. It's just way too convenient!
In this tutorial you will learn:
1) What BEM is, what are Block, Element, and Modifier,
2) How to implement BEM in your HTML & CSS,
3) Why you should take your time to learn BEM.
Timestamps:
0:00 Intro
0:18 What is BEM?
0:45 Breaking HTML into Block and Elements
1:19 Block and Element naming
2:51 What are Modifiers?
3:52 Why BEM?
5:11 BEM with SASS/SCSS
6:11 Summary
#CCS3 #bem #blockelementmodifier

Наука

Опубликовано:

 

19 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@gerar10s
@gerar10s 3 года назад
What I've been reading so far it say that you can only go down one level with the elements. So, in this case Card__body__content is not acceptable because you went 2 levels down. I'm new to this but every document I've seen about the subject talks about this. Has this changed recently? Thanks
@ClosureWebDevMore
@ClosureWebDevMore 3 года назад
Hey! You are absolutely correct. BEM specs state that in this case you should skip the parent element and use just Card__content. However, from my experience, maintaining such class names is more annoying than it is useful. This approach won’t reflect the DOM structure in .scss files and make it more difficult to navigate. It’s my bad and I should have mentioned that in the video. Thanks for correcting me!
@gerar10s
@gerar10s 3 года назад
@@ClosureWebDevMore Great thanks! Like I said, I'm just starting with all this but I have to agree with you. The way you show it here would be my preference. Thanks for the tutorial
@codelightsparkles2403
@codelightsparkles2403 3 года назад
Thank you for this well explained video. You’re a life saver!!
@yuryitikhonoff9631
@yuryitikhonoff9631 3 года назад
Content is awesome. Great job. Thank you so much.
@peterballa6060
@peterballa6060 2 года назад
How a great video thank you! Well explained!
@dorpeled4768
@dorpeled4768 2 года назад
Great video, thanks for that.
@patricknelson
@patricknelson 2 года назад
6:00 - I’m with you 100% on BEM for the stated reasons, but curious: Earlier you mentioned ability to Ctrl+F the codebase to find the class. One issue I’ve encountered with using Sass & prefixes is that it gets in the way of this typically. Do you have a process for that or do you just failover to the manual search (i.e. It’s a “Card” so at least you know where to look) or should you just scrap & prefixes all together in order to preserve searchability? 🤔
@chaitanyashahare2734
@chaitanyashahare2734 Год назад
The intro was epic XD paused the video to comment
@RubberDuckCoding
@RubberDuckCoding 2 года назад
VERY NICE!
@dawid_dahl
@dawid_dahl 2 года назад
Perfect.
@mohanadalhiti4300
@mohanadalhiti4300 Год назад
Thank you 👍
@SuswanaJoel
@SuswanaJoel 5 месяцев назад
Bem
@SuswanaJoel
@SuswanaJoel 5 месяцев назад
Him
@roseuwaezuoke7616
@roseuwaezuoke7616 2 года назад
Thanks
@ClaireSingson
@ClaireSingson 11 месяцев назад
question : im using card__header in one component .. . can i use card__header again in another component?
@emanuelYaish
@emanuelYaish 3 года назад
I very liked the explanation but I have a question, How to implement BEM methodology with other css libraries such as bootstrap or semantic-ui?
@ClosureWebDevMore
@ClosureWebDevMore 3 года назад
Bootstrap and Semantic are the complete opposite of BEM, so there is no real way to use them together. In BEM, class name defines an element and is unique, while in these two frameworks class is just a way to apply a certain style and can be used on many different elements
@emanuelYaish
@emanuelYaish 3 года назад
@@ClosureWebDevMore ok thanks very much for the reply, I asked because sometimes you only take some code from bootstrap like the grid and the rest you write on your own .
@ClosureWebDevMore
@ClosureWebDevMore 3 года назад
You could try using CSS grids and wrap them in a mix-in if you want to reuse that functionality
@emanuelYaish
@emanuelYaish 3 года назад
@@ClosureWebDevMore THANKS!! I will try it.
@jamshediqbal7936
@jamshediqbal7936 3 года назад
If you are already using bootstrap or semantic-ui in your current project, then I won't say anything. But if you don't, then I will prefer not to use these libraries. I'm not against them but in my personal opinion, your own written css is quite enough to make good and challenging design with the help of flexbox, css variables, grid system etc...
@d-landjs
@d-landjs 3 года назад
GJ!
@DiegoVergaraLoza
@DiegoVergaraLoza 3 года назад
It makes no sense to me to nest classes using BEM. I think one of the benefits of it is that it reduces the need for nesting to a minimum by using specific class names
@jfalcao
@jfalcao 3 года назад
Agreed. If anyone else is more interested about this: getbem.com/faq/#css-nested-elements.
@elg281
@elg281 2 года назад
Hey you're right I didn't learn thank you
@RubberDuckCoding
@RubberDuckCoding 2 года назад
My like button turned black, not blue... I think I pressed it too hard
@MaksymMinenko
@MaksymMinenko 3 года назад
Card__header__main-image is a wrong way of using BEM. You don't completely understand the methodology.
@johnny2598
@johnny2598 2 года назад
explain why
@chocofun6612
@chocofun6612 Год назад
@@johnny2598 see the bem guidelines on it's official site
@korkut31
@korkut31 10 месяцев назад
wrong. what u told is wrong. this is not BEM. there is nothing in BEM like x__y__z. this is wrong.
@yogesh-yadav
@yogesh-yadav 9 месяцев назад
6:21 is wrong
@korkut31
@korkut31 3 месяца назад
u are using bem WRONG.
Далее
BEM 101: How to Make Web Design Organized & Scalable
1:01:37
Ракси Манижа бо Салдато 👍
00:41
Просмотров 177 тыс.
ГОРДЕЙ и АНГЕЛИНА РАССТАЛИСЬ.
04:46
Learn CSS BEM (and avoid these common mistakes)
15:36
Просмотров 4,1 тыс.
BEM in 6 minutes - CSS Methodology 2024
6:22
Просмотров 31 тыс.
CSS Modules: Why are they great?
12:03
Просмотров 38 тыс.
Learn Flexbox CSS in 8 minutes
8:16
Просмотров 1,3 млн
Every CSS Animation property
9:26
Просмотров 49 тыс.
Sass and BEM for beginners
3:45:10
Просмотров 235 тыс.
Learn Every CSS Selector In 20 Minutes
19:38
Просмотров 433 тыс.
подключение в противофазу
0:56
Просмотров 262 тыс.