How to make SVG images scale using the CSS “width” property?

Spread the love

Sometimes, we want to make SVG images scale using the CSS “width” property.

In this article, we’ll look at how to make SVG images scale using the CSS “width” property.

How to make SVG images scale using the CSS “width” property?

To make SVG images scale using the CSS “width” property, we remove the width attribute from the svg.

For instance, we write

<svg viewBox="0 0 12 20">...</svg>

to add an svg without the width attribute to make SVG images scale using the CSS width property outside the svg element.

Conclusion

To make SVG images scale using the CSS “width” property, we remove the width attribute from the svg.

Leave a Reply

Your email address will not be published. Required fields are marked *