What is the best way to change the CSS of one element when hovering over another element in CSS?
We can achieve this using the following code:
.example .example2 li:hover .element
If our HTML looks like this:
<div class='example'><div class='example2'><li></li></div></div>
<div class='element'></div>
But if we have:
<div class='example'><div class='example2'><li></li></div></div>
<div class='exemple2'><div class='element'></div></div>
We cannot use
.example .example2 li:hover .exemple2 .element
Is there a way to target the child element .element
when hovering over its parent element .example2
?