user3698196 user3698196 - 7 months ago 41
jQuery Question

How to resize a svg to fit inside a div?

on trying fitting in to div(with border) svg is cut off from the right size.



<div style="position:relative;width:550px;height: 500px;background: gainsboro;border: 4px solid;">

<-- My SVG -->


help me fit this svg in 550x500


Don't use width or height in your SVG.

Use viewbox instead. Then the SVG will scale automatically (mostly).

<svg xmlns="" viewbox ="0 0 959 593">

Codepen Demo