【发布时间】:2020-07-11 00:30:05
【问题描述】:
我想在悬停时使用 css 更改 svg 的每个多边形的颜色。
这是hmtl代码:
<svg class="compass-svg" width="200" height="200">
<polygon id="N" points="100,10 125,50 100,100 75,50" style="fill:#fff; stroke:#000; stroke-width: 1;"/>
<polygon id="NE" points="155,45 150,75 100,100 125,50" style="fill:#fff; stroke:#000; stroke-width: 1;"/>
</svg>
当我悬停其中一个多边形时,它的填充应该变成#000。
我已经尝试使用 id 更改颜色:
/*This does not work*/
#N:hover {
fill: #000;
}
我使用 jquery 找到了这个解决方案,但我想知道这是否可以使用纯 css 来实现: my svg polygons fills are not changing color on hover
【问题讨论】: