Currently, I am studying SVG and have a question about changing the circle fill value of the second use element. Here is what I have tried:
* {
stroke: brown;
stroke-width: 1;
fill: none;
}
.canvas{
border-color: green;
border-style: solid;
border-width: 1px;
}
.sun > circle{
fill: yellow;
}
.hot-sun > circle {
fill: red;
}
<?xml version='1.0'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/DTD/svg11.dtd'>
<?xml-stylesheet type='text/css' href='../css/index.css'?>
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='1400' height='1000' viewBox='0 0 1400 1000' class='canvas'>
<title>SVG learning</title>
<desc>This is my sandbox</desc>
<defs>
<g id='foo' class='sun'>
<rect x='0' y='0' width='50' height='50'/>
<circle cx='25' cy='25' r='10'/>
</g>
</defs>
<g id='dwg'>
<use xlink:href='#foo' transform='translate(10 10)' />
<!-- Here I expected my sun will be red...-->
<use xlink:href='#foo' transform='translate(10 70)' class='hot-sun'/>
</g>
</svg>