Reputation: 5
I am working with svg sprite and having trouble showing the icons. Only the first icon is showing from the sprite the rest are not. Can someone please help?
I am making reference to the svg icon on the html file and referring to a sprite sheet:
<i class="icon icon-desktop-wallet">
<svg width="145" height="145" viewBox="0 0 53 32">
<use xlink:href="sprite.svg#icon-image-desktop-wallet"></use>
</svg>
</i>
here is it on plunker: https://plnkr.co/edit/9uJBGIsti0okemimjcNM?p=preview
not too sure what i have missed here
thanks
Upvotes: 0
Views: 2520
Reputation: 123995
In the sprite.svg file the x of each element changes e.g. for icon-image-bg-cloud the x value is 37.
<svg id="icon-image-bg-cloud" width="55" height="32" viewBox="0 0 55 32" x="37" y="0">
...
</svg>
This means when you display it with a viewBox="0 0 29 32" you don't see anything as the sprite is outside the viewable area.
You could fix this by either
Option 2 seems easiest to me FWIW.
Upvotes: 1