Lee Lee - 1 month ago 9
CSS Question

CSS - Change border-color of div within anchor:hover

I have a div contained within an anchor like so:

<a class="chk" href="href">
<div class="chk-div"></div> Text Here
</a>


I want it so that when you hover over the
<a>
, the border-color of the child
<div>
changes. I know you can do it simply for the div like so:

.chk-div:hover {
border-color: green;
}


But I want it to change when you hover over the text also

Answer

Is this the sort of thing you're after?

.chk:hover .chk-div {border: solid 1px green;}

https://jsfiddle.net/d7tc0sq8/