X
X
Xenia2017-04-03 08:39:46
css
Xenia, 2017-04-03 08:39:46

Is it legal to use :nth-child() in BEM?

I have 4 .clients__client elements in my .clients block. They differ from each other only in the background image. Is it possible to set this picture via :nth-child(1-4)? Or does each need to be given a modifier? Or even put these pictures in img inside these elements? You can do it either way, but how would it be correct from the point of view of BEM?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Goryachev, 2017-04-03
@TGNC

From a BEM point of view, it would be correct to make modifiers.

.clients__client--client1
.clients__client--client2
.clients__client--client3
.clients__client--client4

nth for isolated cases it is better not to use it at all. Only for repeating, logical.
For example, every 3, every 5th number, the first 4 or more complex pattern, but repeating.
If you put pictures inside the elements, they should still have their own class, I don’t see the point.
Since according to BEM, every tag must have a class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question