Closed esomkin closed 6 years ago
Hi, thanks for the clear example case. That made it very easy to figure out what the problem is.
The :first-child
CSS isn't getting applied to the rectangle because the exported SVG's first child is a <defs>
element that defines all the styles. rect:first-child
doesn't match, but rect:nth-child(2)
does.
I suggest you wrap your rect
s in a g
tag with a known class that you can use in your selector. Then :first-child
will work as expected.
At the moment I'm not sure what a better solution is, but I'm open to suggestions.
Thank you for your clarification! But, how is you understand that the first child is <defs>
? Did you using some debug tool to see exported result SVG?
You can get the SVG code with the prepareSvg
function. For example,
prepareSvg(document.querySelector('.svg-root'), {}, svg => console.log(svg));
Thank you very much!
Hi!
I need to export simple SVG element (two rectangles) into PNG format. First rectangle has red color, last is green. In browser all ok, but in export file first rectangle is black.
Test code is here
How can I paint a rectangles in correct colors? There is no possibility to assign class or id to rectangles.
Thanks in advance.