on trying fitting in to div(with border) svg is cut off from the right size.
PEN
HTML
<div style="position:relative;width:550px;height: 500px;background: gainsboro;border: 4px solid;">
<-- My SVG -->
</div>
help me fit this svg in 550x500
on trying fitting in to div(with border) svg is cut off from the right size.
PEN
HTML
<div style="position:relative;width:550px;height: 500px;background: gainsboro;border: 4px solid;">
<-- My SVG -->
</div>
help me fit this svg in 550x500
Share Improve this question edited Jul 8, 2016 at 9:52 elreeda 4,5972 gold badges21 silver badges45 bronze badges asked Jul 8, 2016 at 9:51 user3698196user3698196 931 silver badge8 bronze badges 1-
1
The
viewBox
of svg should be in aspect ratio of 550X550. – Mr_Green Commented Jul 8, 2016 at 9:55
1 Answer
Reset to default 8Don't use width
or height
in your SVG.
Use viewbox
instead. Then the SVG will scale automatically (mostly).
<svg xmlns="http://www.w3/2000/svg" viewbox ="0 0 959 593">
Codepen Demo