Cross browser SVG preserveAspectRatio

后端 未结 5 853
渐次进展
渐次进展 2021-02-01 18:40

I\'m trying to have a SVG graphic inside an tag that would fit (without crop) inside the tag with preserved aspect ratio. I created t

5条回答
  •  青春惊慌失措
    2021-02-01 19:14

    Just thought that I would add how I stepped into a solution. I had trouble figuring out some of the issues at first.

    1. Edit your SVG file to remove the hard-coded height and width attributes. (with simple text editor)
    2. Apply width:100% css to your svg image to make IE display it like other browsers. (as big as it's container)
    3. Use css on your image container for consistent results!

    I made a page to describe it in more detail at http://ivantown.com/posts/svg-scaling-with-ie/

提交回复
热议问题