Is there any selector in CSS which selects every <element2> element before a <element1> element? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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