I'm trying to create a layout with 3 <div>
elements in one horizontal line, each with a width of 33.33%. When hovering over one div
, I want its width to expand to 50% while the other two shrink to 25%.
<div id="A"></div>
<div id="B"></div>
<div id="C"></div>
I have successfully applied this effect to div A:
#A:hover{width:50%}
#A:hover+#B
{width:25%}
#A:hover~#C
{width:25%}
It works as expected for A. However, when hovering over B:
#B:hover{width:50%}
#B:hover+#A
{width:25%}
#B:hover~#C
{width:25%}
B expands to 50% and C shrinks to 25%, but A remains at 33.33%. How can I resolve this issue?