[英]Embedding an SVG within another SVG as an Image is not appearing when referenced from HTML
I wasn't sure how to word it correctly for the title, but here's what is happening. 我不确定标题的正确用词方式,但这就是正在发生的事情。
I have two SVG files within the same folder, shapes.svg
and wrapper.svg
我在同一文件夹中有两个SVG文件
shapes.svg
和wrapper.svg
wrapper.svg
references shapes.svg with an image tag wrapper.svg
使用图像标签引用shapes.svg
<image x="-75" y="-100" width="150" height="150" xlink:href="shapes.svg" />
Now if I view wrapper.svg
within a web browser directly, I can see it rendering shapes.svg
perfectly. 现在,如果我直接在Web浏览器中查看
wrapper.svg
,我可以看到它完美地呈现了shapes.svg
。 However, if I attempt to view wrapper.svg
with a HTML file which is one directory above these two files, I can see all the markup of wrapper.svg
, but it does not show shapes.svg
. 但是,如果尝试使用HTML文件查看
wrapper.svg
,该文件是这两个文件上方的一个目录,则可以看到wrapper.svg
所有标记,但不会显示shapes.svg
。
Within the HTML file I am simple doing 在HTML文件中,我很简单
<img src="svg/wrapper.svg" style="width:150px;height:150px;" />
The folder structure is as follows 文件夹结构如下
I found this a bit difficult to explain, and have attempted my best to relay the problem. 我发现这很难解释,并尽力解决了这个问题。 If anybody needs me to further clarify anything at all, please do just ask me and I will reply promptly.
如果有人需要我进一步澄清任何事情,请问我,我会尽快答复。
For privacy reasons all images must be single files. 出于隐私原因,所有图像都必须是单个文件。 You can have an image within your image but the inner image must be encoded as a data URI.
您可以在图像中包含图像,但是内部图像必须被编码为数据URI。
When thinking of an SVG as an image it helps to think... "If this was a raster image, could I do this". 当将SVG视为图像时,它有助于思考...“如果这是光栅图像,我可以这样做”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.