Say I have the following
.selected {
font-weight: bold;
}
.selected ~ div {
color: red;
}
<div class="numbers">
<div><p>1</p></div>
<div><p>2</p></div>
<div class="selected"><p>3</p></div>
<div><p>4</p></div>
<div><p>5</p></div>
</div>
Within these 5 divs, the position of the selected div may change (ie the user clicks something and now 2 is selected instead of 3), hence why I need these fancy CSS rules.
I can select divs that come after the selected element. How do I select divs that come before it?
I've tried something like .numbers div:not(.selected ~ div){}
, but that doesn't seem to work.