Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG <image> not showing on iphone

So I'm trying to link an image (rocket.svg) into my svg but when I embed it into my site the svg shows but not the rocket.svg

<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" style="position:fixed; top:0;      left:0; height:100%; width:100%; user-select: none;">
   <rect style="fill:#33425B;" width="100%" height="100%" id="background"/>

    <!-- Rocket -->
    <image xlink:href="rocket.svg" x="15%" y="45%" width="10vw" height="10vw" id="rocket"/>
</svg>
like image 371
Mason Wright Avatar asked Feb 14 '17 02:02

Mason Wright


People also ask

Why is my SVG not appearing?

If you are trying to use SVG like <img src="image. svg"> or as a CSS background-image , and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type.

Can you use SVG files on iPhone?

With a recent Software Update to Apple devices (iPhones and iPads), you can now upload SVG files to Design Space directly from your phone!

How do you use SVG images in iOS?

For using SVG, you only need to drag them in your assets folder and then you can use them in your project file by using UIImage class named constructor.


2 Answers

Using vw with your height and width attributes is what is causing the problem, changing it works:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" style="position:fixed; top:0;      left:0; height:100%; width:100%; user-select: none;">
  <rect style="fill:#33425B;" width="100%" height="100%" id="background"/>
  <image x="0" y="0" width="100%" height="100%" xlink:href="https://upload.wikimedia.org/wikipedia/commons/a/a3/NASA_Worm_logo.svg" id="tiger" />
</svg>
like image 114
l'L'l Avatar answered Sep 28 '22 00:09

l'L'l


Just putting this out there for future folks that have a similar problem. I'm very amateur and was using elementor with wordpress and having problems with my SVGs showing on apple devices. I found the following tool and it fixed my problems!

https://jakearchibald.github.io/svgomg/

like image 27
Hal Avatar answered Sep 28 '22 00:09

Hal