user3698196 user3698196 - 1 year ago 139
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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download