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...

28th Jun 2020, 2:35 PM
Avishek Chowdhury
Avishek Chowdhury - avatar
3 Answers
+ 4
No, there isn't.
28th Jun 2020, 2:45 PM
Gordon
Gordon - avatar
+ 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.
28th Jun 2020, 2:56 PM
CalviŐ˛
CalviŐ˛ - avatar
0
OK. I got it... 🙂 Thanks Gordon Calviղ
28th Jun 2020, 10:21 PM
Avishek Chowdhury
Avishek Chowdhury - avatar