hover
is enabled on an element, the right siblings should receive a unique style, while those on the left should receive another style. I currently have the same code working fine in JS to stylize the left siblings of the element in hover
however, I feel bothered not to be able to do everything just with CSS, so the question is, can you select all siblings before selected using CSS ?
.main{
width: 100%;
height:50px;
}
.child{
width:50px;
height:50px;
background-color:#F00;
display: inline-block;
margin-right: 5px;
}
.child:hover{
background-color: #0F0;
}
/*define cor para todos os siblings depois deste*/
.child:hover ~ .child{
background-color: #00F;
}
<div class="main">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>