I would like to apply styling to list items in ordered list (specifically to the ::after or ::before), based on the classes of the <li>
. The code for these lists looks like the following:
<ol>
<li class="class1">Item 1</li>
<li class="class1">Item 2</li>
<li class="class1">Item 3</li>
<li class="class2">Item 4</li>
<li class="class2">Item 5</li>
</ol>
The lists are generated automatically, and the position of the first class2
item may vary inside the list (it can even be absent in some case, leaving only class1
items in the list).
I would like to add something in the ::before
of the first item of each class (like a specific header for each type of item in my list). Ending up with something like this:
Example of expected result
Anyone could help me with the CSS selector to use for this? I tried several things with +
or ~
but nothing works seems for now...
Thanks!
David