Why Isn't My SVG Image the Right Size in Internet Explorer

My svg images looked fine in the good browsers, but in Internet Explorer, they were appearing huge!  I attempted to just set the size using css in the image tag, but that didn't work. 

 

What actually did work, was I opened up the svg file, and added a "viewBox" value to the svg declaration, so I my file looked something like this:

 

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="400"
height="360" 
viewBox="0 0 400 360"
....

 

So the viewbox numbers, I just set this to start at the top left (the two 0's), and then set the other corner of the viewbox with the 400 (the width), and the 360 (the height). This change fixed it.




Related Posts


Fixed Position Div Isn't Staying Fixed When Scrolling on Android

My nice fixed position toolbar wasn't sticking as it should as I scrolled through on my mobile browser window...
Read Post

Simple Sticky Element

The user scrolls down the page and once the scrolling reaches the top of an element of my choosing, that element sticks to the top of the window, so it's always visible from that point on...
Read Post

Chrome displays a different height than what Chrome says the height should be.

I was changing the height of an element, but no matter where I specified the height, it wasn't displaying what I was putting in
Read Post

A Nicer Select Dropdown

Better select boxes are all over the internet, but I actually couldn't find one that I liked, and that worked for what I needed...
Read Post