Responsive SVG

How do I get my SVG to fit inside its container?

heres my code.
It should fill 100% of the card-body div

			  <div class="card-body">
<svg fill="#ececec" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width=".2" viewbox="0 0 1000 478" xmlns="">

What have you tried so far?


Oh, I tried a bunch of things, the thing that worked was if I gave it only a viewBox (no width, height of the preserveaspect ratio.

Assuming card-body has a width defined then set the svg to width:100% and height:auto in the css.


1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.