0
Is there any selector in CSS which selects every <element2> element before a <element1> element?
element1 ~ element2 selects every <element2> element that are preceded by a <element1> element. Is there any selector in CSS which selects every <element2> element before a <element1> element? I searched a lot. But can't find anything like this...
3 ответов
+ 4
No, there isn't.
+ 3
Css can only select element after, not before.
However, if you really want to select an element before another element (visually), there is an indirectly workaround way, by using flexbox.
Check out this sample
https://code.sololearn.com/WFlGZnHMBIho/?ref=app
The arrangement of the element on css codes, is still select the element after, but we can relocate the elements position using order selector.