+ 2
what actually width and height indicates in SVG
<svg width="2000" height="2000"> <circle cx="80" cy="80" r="50" fill="green" /> </svg> when i change svg width and height again it give sameresults why?
3 RĂ©ponses
+ 4
In the ârealâ world, before you draw something you get a piece of paper.
Well, <svg width="2000" height="2000"> creates an âimaginaryâ piece of paper that is 2000 units wide, by 2000 units high.
And then you draw a circle, somewhere on your paper. Where exactly you place the circle, how âbigâ is your circle and what âit looks likeâ, is given by the next line:
<circle cx="80" cy="80" r="50" fill="green" />
Your circle has a radius of 50 units, its centre is located 80 units to the right from the left edge of your paper, and 80 units below from the upper edge of your paper. And it is all green.
As long as you draw the circle inside the âimaginaryâ paper you have created, you donât see any easily visible difference â itâs only the âbig pictureâ that changes (i.e. where in relation to the whole area of the paper the circle is placed).
But if you set width=â100â, height=â100â, then you will find out that the circle is incomplete â just because your âpaperâ is too small for the circle you want to draw, where you want to draw it. And this time, you have a difference that is easily visible.
Hope this helps.
0
The width and height attributes of the <svg> element define the width and height of the SVG image.