OK, let's say I have a similar structure like the one following :
<div comp-id='one'>
<div comp-id='two'>
<div comp-id='three'>
...
</div>
</div>
</div>
All I want to do is to apply a hover effect to the child (in this case, the one with comp-id="three"
).
IMPORTANT NOTE : I don't want to target specifically [comp-id="three"]
. I want to target any child, with no-matter-which comp-id
value. In the real-world example, there may be infinite nested [comp-id]
ed div
s. I just need the innermost child.
What I'm trying to achieve :
- User hovers over
three
, then justthree
is highlighted (notone
andtwo
) - User hovers over
two
, then justtwo
is highlighted (notone
- and, of course, notthree
)
My current CSS code :
[comp-id]:hover {
box-shadow: inset 0 0 0 2px red;
-webkit-box-shadow: inset 0 0 0 2px red;
-moz-box-shadow: inset 0 0 0 2px red;
-o-box-shadow: inset 0 0 0 2px red;
}
However, my current CSS highlights everything which is not what I want. I could think of a javascript-based solution. What about CSS?
Warning : I'm not such a guru with CSS, so this may be really simple... :-)