2

I know if i add the hole SVG code in HTML i can access all the layers via CSS. But in this case i want to have my SVG as a separate file and then in HTML i'm linking to it. But is it possible to access the layers in CSS?

<div class="test"><img src="file.svg" /></div>

So i have tried this:

let poly_shapes = function myfunction() {
var x = document.getElementById("svg1");
var y = x.contentDocument.getElementById('clouds_1_');
return y;};

HTML i have:

<object id="svg1" data="pilis.svg" type="image/svg+xml"></object>

Before this if i had my svg code in html this JS would work

let poly_shapes = $('#clouds_1_')
Marius
  • 1,664
  • 2
  • 16
  • 28
  • You can't.....it's an SVG image not an actual SVG – Paulie_D Dec 10 '18 at 16:58
  • 1
    https://stackoverflow.com/questions/31128970/how-do-you-style-a-external-svg-with-css?noredirect=1&lq=1 – Paulie_D Dec 10 '18 at 17:00
  • Ok so i can see 2 solutions add the code to my CSS main file. or try JS : "You can grab a hold of the external images' tree with JavaScript and edit their styles from there. The keyword for that would be contentDocument, see this answer." – Marius Dec 10 '18 at 17:04
  • so i have tried JS version, i have left my update on top – Marius Dec 10 '18 at 17:26

0 Answers0