Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change aspect ratio of svg in HTML

Tags:

html

css

svg

Using HTML and CSS, how do you change the size of an SVG (using an <img /> tag to get svg file) WITHOUT keeping the aspect ratio?

like image 703
vcapra1 Avatar asked Jul 13 '13 15:07

vcapra1


1 Answers

Just add preserveAspectRatio="none" to the <svg> root element. Or if you want you can override it when linking to the img, like in this example, by using a link like this:

<img src="your.svg#svgView(preserveAspectRatio(none))" />

For a live example, try this and resize the browser window.

like image 99
Erik Dahlström Avatar answered Oct 25 '22 20:10

Erik Dahlström