I have 3 divs, A, B & C, and each have 3 different backgrounds depending on which of the three div is hovered over.
The idea is to change background of the divs as follows:
- On hover of
A, changeAbackground toa1,Btob1andCtoc1 - On hover of
B, changeAbackground toa2,Btob2andCtoc2 - On hover of
C, changeAbackground toa3,Btob3andCtoc3
It seems that when trying to change the background of a div that comes before the :hover div it fails.
HTML
<div class="team1"></div>
<div class="team2"></div>
<div class="team3"></div>
CSS
.team1 {
background: url("url of IMAGE1/a");
}
.team2 {
background: url("url of IMAGE2/a");
}
.team3 {
background: url("url of IMAGE3/a");
}
.team1:hover {
background: url("url of IMAGE1/b");
}
.team2:hover {
background: url("url of IMAGE2/b");
}
.team3:hover {
background: url("url of IMAGE3/b");
}
.team1:hover ~ .team2 {
/* this works */
background: url("url of IMAGE 2/c");
}
/* this works */
.team1:hover ~ .team3 {
/* this works */
background: url("url of IMAGE 3/c");
}
.team2:hover ~ .team1 {
/* this doesn’t work! */
background: url("url of IMAGE 1/c");
}