Two tricks. Basically inverting the HTML order of your desired elements in HTML and using
~
Next siblings operator:
float-right
+ inverse the order of HTML elementsdiv{ /* Do with the parent whatever you know just to make the_x000D_
inner float-right elements appear where desired */_x000D_
display:inline-block;_x000D_
}_x000D_
span{_x000D_
float:right; /* float-right the elements! */_x000D_
}_x000D_
span:hover ~ span{ /* On hover target it's "previous";) elements */_x000D_
background:red;_x000D_
}
_x000D_
<div>_x000D_
<!-- Reverse the order of inner elements -->_x000D_
<span>5</span>_x000D_
<span>4</span>_x000D_
<span>3</span>_x000D_
<span>2</span>_x000D_
<span>1</span>_x000D_
</div>
_x000D_
direction: rtl;
+ inverse the order of inner elements.inverse{_x000D_
direction: rtl;_x000D_
display: inline-block; /* inline-block to keep parent at the left of window */_x000D_
}_x000D_
span:hover ~ span{ /* On hover target it's "previous";) elements */_x000D_
background:gold;_x000D_
}
_x000D_
Hover one span and see the previous elements being targeted!<br>_x000D_
_x000D_
<div class="inverse">_x000D_
<!-- Reverse the order of inner elements -->_x000D_
<span>5</span>_x000D_
<span>4</span>_x000D_
<span>3</span>_x000D_
<span>2</span>_x000D_
<span>1</span>_x000D_
</div>
_x000D_