0
why i have to add value of width and height next to svg and next to rect
hi guys i have one question <svg width="2000" height="2000"> <rect width="300" height="100" x="20" y="20" fill="green" /> </svg> i don`t understand what is the difference between <svg width="2000" height="2000"> and rect width="300" height="100"
6 Réponses
+ 5
Svg is a method to draw any 2-D shapes and rect is a part of that . Do you need to first desied SVG and then it's shapes
+ 4
BroFar i don't know about canvas sir thanks a lot😊
+ 4
®OHiT_$HaRma ™ okay think in terms of a piece of paper and you are drawing on it... you have a set 10½ by 8 size sheet and want to draw an apple an orange and a banana in a bowl
+ 2
svg is the canvas, setting is width and height affects its size on the webpage
rect is for a rectangle, you need to specify its width and height and also position.
If rectangle size exceeds canvas size, it'll be cropped, see example 2.
solution is viewBox attribute, see example 3.
https://code.sololearn.com/WgBw7Yq20ZkR/?ref=app
+ 2
®OHiT_$HaRma ™ yes you need a background similarly to js canvas thinking the SVG tags set the sheet size and width before you can draw on / in it
0
thanks for help