svg中改变class调用的线条颜色

时间:2021-03-11 06:00:33

<style type="text/css"><![CDATA[

.kV220 {stroke:rgb(255,0,0);fill:none}

.kV22 {stroke:rgb(0,255,255);fill:none}

.kV110 {stroke:rgb(255,255,0);fill:none}

]]></style>

<g id="617">

<use x="0" y="0" width="28.0" height="36.5" xlink:href="#Disconnector:普通刀闸_0" id="GHB.220.6022_I" commid="GuiH_S.220.6022_I" class="kV22" style="stroke:red"/>

</g>

---------------------------------------------------------------------------------

用use,使用class,class="kV22",这是要改变kV22中写的颜色:stroke:rgb(0,255,255);

正确方法是在use中补写属性:style="stroke:red",即:

<use ... commid="GuiH_S.220.6022_I" class="kV22" style="stroke:red"/>

用别的写法都不行,包括:stroke="red"