While the actual parent selector is not possible through CSS, you can “hack” it for your case using extra elements and positioning.
What you need is to change the background based on what element is hovered — ok! Let's add pseudo-elements (or normal elements if you'll need IE support) and position them over the parent using absolute positioning and positive z-index
:
#buttonBox {
position: relative;
z-index: 1;
}
#buttonBox > div:before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
}
Those positioned elements should have negative z-index
, so they would be placed under all other content, but over the parent element's background.
This way you could add rules like
#schedBox:hover:before { background: lime; }
#transBox:hover:before { background: red; }
#destBox:hover:before { background: orange; }
#inspirBox:hover:before { background: yellow; }
And the pseudo-background of the parent would change on hover!
The only thing to know is that there shouldn't be any elements with non-static position between the parent and the elements with the background role.
Here is the live example at dabblet
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…