2

I am working with svg and its dom manipulation. I want to create a border for a group of svg elements positioned inside the <g> tag. How do I do this? Is it possible to create circular / elliptical boundaries also? I am using the jQuery SVG library. Thanks in advance

<g>
<rect x="20" y="30" width="200" height="300" fill = "red"/>
<circle cx="40" cy="50" r="25" fill="blue"/>
</g>
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
Srikrishnan Suresh
  • 729
  • 2
  • 13
  • 31

2 Answers2

9

You cannot add a border to containers like <g> or <svg>, since they are not supposed to render anything directly by themselves. You may want to look how this demo is implemented using the cross browser implementation of getScreenBBox();

Emil
  • 714
  • 1
  • 5
  • 10
-17

In your CSS you could add:

rect {border: 1px solid #00f;}
austincheney
  • 1,189
  • 9
  • 11