You can not change the fill
via :hover
in <style>
because it is already set via style inline :
<path style="fill:#ffffff;stroke-width:1.95499432"...
For
:hover
to work in
<style>
you should set
fill
to
<style>
, and you can also use
stroke-width
, and remove
style
from element:
Element without style:
<path d="m 409.51823,171.04465 c -1.61287,-0.34827 -8.87078,-1.19599 -16.1287,-1.88382 l -13.19621,-1.2506 v -25.25932 -25.25932 l 10.26372,0.0148 c 9.75768,0.014 34.79672,3.33913 36.27473,4.81715 0.64735,0.64736 -6.48667,38.8851 -8.67303,46.48669 -0.95153,3.30828 -2.31046,3.67973 -8.54051,2.33446 z"
id="d1s1"
inkscape:connector-curvature="0"
transform="matrix(0.26458333,0,0,0.26458333,4.9999997,48.5)"
inkscape:label="d1s1" />
CSS for # d1s1:
<style>
#d1s1 {
fill:#ffffff;
stroke-width:1.95499432;
transition: fill 2s;
}
#d1s1:hover {
fill: #ffff00;
}
</style>
The ideal is to apply to path
(since all are path
) and not every id
, so it would be:
path {
fill:#ffffff;
stroke-width:1.95499432;
transition: fill 2s;
}
path:hover {
fill: #ffff00;
}
To change the color on the click, create classes with colors and add via JavaScript. For example, create a class for the green color:
.verde{
fill: #090;
}
Add a dataset cor
with the name of the class in path
according to the color you want for it when clicked:
<path data-cor="verde" d="m 409.51823,171.04465 c -1.61287,-0.34827 -8.87078,-1.19599 -16.1287,-1.88382 l -13.19621,-1.2506 v -25.25932 -25.25932 l 10.26372,0.0148 c 9.75768,0.014 34.79672,3.33913 36.27473,4.81715 0.64735,0.64736 -6.48667,38.8851 -8.67303,46.48669 -0.95153,3.30828 -2.31046,3.67973 -8.54051,2.33446 z"
id="d1s1"
inkscape:connector-curvature="0"
transform="matrix(0.26458333,0,0,0.26458333,4.9999997,48.5)"
inkscape:label="d1s1" />
And create in JavaScript create a click event for each path
that will apply the class according to the color of the dataset cor
of the clicked element:
<script>
var paths = document.querySelectorAll("path");
for(var x=0; x<paths.length; x++){
paths[x].addEventListener("click", function(){
this.classList.add(this.dataset.cor);
});
}
</script>