Answer the question
In order to leave comments, you need to log in
How can I change the color of the svg path using css when hovering over a div?
There is a map on svg with areas whose names are added via divs with absolute positioning. It is necessary that when you hover over the name in the div, the color of the path changes.
Sample html structure:
<div id="map">
<svg style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path class="region" d="..." id="region_1"></path>
<path class="region" d="..." id="region_2"></path>
<path class="region" d="..." id="region_3"></path>
</svg>
<div class="region_name name_region_1">Region 1</div>
<div class="region_name name_region_2">Region 2</div>
<div class="region_name name_region_3">Region 3</div>
</div>
#map .region_name:hover #map path {
fill:red;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question