0

I have a vector file that contains 40 svgs all in one image. Each vector has an id inside <g> tag and I want to know how to select a certain svg from that 1 file without selecting all the image in html.
PD: Each vector has its own dimensions.

Thanks

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
NyTrOuS
  • 63
  • 1
  • 12

2 Answers2

1

you can either add this svg tag into your html to have it drawn together with the rest of the html or, you could load it from a file on your server by using this

<svg viewBox="0 0 100 100">
   <use xlink:href="path-to-your-svg:#the-id-of-the-object-you-want-to-load"></use>
</svg>
Odinh
  • 183
  • 2
  • 15
  • I've written this " " inside my html code and it hasn't worked. Do you know why? – NyTrOuS Feb 03 '18 at 22:00
  • i would like to refere you to [this awnser](https://stackoverflow.com/a/22996360/8040906) it goes in more detail than i'm able to do in a propper way – Odinh Feb 04 '18 at 10:35
0

without any source i can only guess,

you could use #the-containing-id:nth-child(n){ ... } where # is the numerical equivalent to the svg if it's just svgs you could use svg:nth-of-type(n){ ... }

also if that one particular svg has an id you can just use it's id, #svgs-id{ ... }

please provide more information and source so we can awnser your question more accurately

Odinh
  • 183
  • 2
  • 15
  • Thank you for helping me Odnh. So I'm using these vectors: https://www.behance.net/gallery/26241257/FREE-Elegant-Vector-Kit-with-60-Workspace-Elements in my website: https://marcelmiro2000.github.io/MarcelMiro and I want to know how I could, instead of importing to my html file each vector using tag for separate, how could I only use 1 file to import all these vectors. Sorry if I'm explaining very badly, – NyTrOuS Feb 03 '18 at 20:46
  • @MarcelMiro let's say you use the SVG "nastifunny without shadows and background .svg" you can call all the elements with their ID using #(theirid) a.e. `#iMac{transform: rotate(45deg);}` – Odinh Feb 03 '18 at 21:06
  • but what would be the html code that you would use to add the svg to a website? Thanks again for the help. – NyTrOuS Feb 03 '18 at 21:20