0

this isn't just an issue in IE 9 & 10, but also older versions of Safari like 5.1.7

I want to use an SVG image sprite and it looks fine on all the latest versions of Chrome, Firefox, and IE, but on IE 9 & 10, it makes the image look squashed and not displaying at the correct size.

Please view this JS fiddle: http://jsfiddle.net/NGSM3/3/ in IE 9, IE 10, or Safari 5.1.7 to see the problem. I want to continue using image sprites for this, but want to update them to an SVG image sprite.

My HTML:

<ul class="svg-nav">
    <li>
        <a><span class="item1"></span></a>
    </li>
    <li class="selected">
        <a><span class="item2"></span></a>
    </li>
    <li>
        <a><span class="item3"></span></a>
    </li>
    <li>
        <a><span class="item4"></span></a>
    </li>
</ul>

My CSS:

*{
    margin: 0;
    padding: 0;
}

.svg-nav{
    background: #fff;
    display: block;
    width: 415px;    
    list-style: none;
}
    .svg-nav li{
        float: left;
    }
        .svg-nav a{
            border-right: 1px solid #eee; 
            cursor: pointer; 
            display: inline-block;
            padding: 9px 35px 6px 35px;
        }
        .svg-nav li:last-child a{
            border-right: none; 
        }
        .svg-nav li a:hover, .svg-nav .selected a{background: #ddd;}
            .svg-nav li a span{
                background-image: url("http://www.endpop.co/svg-test.svg");
    background-repeat: no-repeat;
    cursor: pointer;
    display: inline-block;
    height: 33px;
    width: 33px; 
    background-size: 133px 66px; 
}
        .item1{ background-position: 0 0; }
        .item2{ background-position: -33px 0; }
        .item3{ background-position: -66px 0; }
        .item4{ background-position: -99px 0; }
user933061
  • 13
  • 1
  • 8

1 Answers1

1

I experienced the same problem. The solution for me, suggested as an answer in this related question Background-size with SVG squished in IE9-10, was to add width and height attributes to the svg element in my SVG file.

Community
  • 1
  • 1
kaa
  • 1,471
  • 2
  • 13
  • 18