SVG不会显示 [英] SVG won't display

查看:100
本文介绍了SVG不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < a href =#target = _blankstyle =display:inline-block;> 
< object data =icons / chrome.svgtype =image / svg + xmlstyle =pointer-events:none;>
后备文本
< / object>
< / a>

当我使用

  data =http://images3.wikia.nocookie.net/__cb20120330024139/logopedia/images/d/d7/Google_Chrome_logo_2011.svg

有效。但是,当我将这个确切的文件保存到我自己的服务器上并参考它时,它只是显示Firefox中的后备文本。在Chrome浏览器下载文件时,我打开页面(这证明文件链接是正确的)。



任何人都知道这里发生了什么?

解决方案

我可以考虑四种可能性:
$ b


  1. 您的服务器对SVG图像使用了错误的MIME类型。 (可以通过在你的.htaccess文件中加入 AddType image / svg + xml svg 来修复; 这里讨论的其他方法

  2. 你将SVG文件保存在其他地方,它不存在在图标/ chrome.svg 。 (尝试直接导航到图标/ chrome.svg上的SVG文件,它是否显示在浏览器中?)

  3. 您保存文件的权限不足,导致在您的Web服务器无法访问该文件。 (可以通过导航到图标目录并在命令行提示符下输入 chmod 0644 chrome.svg 来修复。) 从nocookie.net下载的文件实际上并不是一个SVG文件。 (尝试在文本编辑器中打开它。)


I'm trying to get this simple code to work:

<a href="#" target="_blank" style="display: inline-block;">
    <object data="icons/chrome.svg" type="image/svg+xml" style="pointer-events: none;">
        fallback text
    </object>
</a>

When I use

data="http://images3.wikia.nocookie.net/__cb20120330024139/logopedia/images/d/d7/Google_Chrome_logo_2011.svg" 

it works. However when I save that exact file onto my own server and reference it as above, it just shows the fallback text in Firefox. In Chrome it downloads the file when I open the page (which proves that the file link is correct).

Anyone know what's going on here?

解决方案

I can think of four possibilities:

  1. Your server is using the wrong MIME type for SVG images. (Can be fixed by adding AddType image/svg+xml svg to your .htaccess file; other methods discussed here)

  2. You saved the SVG file somewhere else and it doesn't exist at icons/chrome.svg. (Try navigating straight to the SVG file at icons/chrome.svg. Does it display in your browser?)

  3. You saved the file with insufficient permissions, resulting in your web server being unable to access the file. (Can be fixed by navigating to the icons directory and typing chmod 0644 chrome.svg at the command line prompt.)

  4. The file you downloaded from nocookie.net isn't actually an SVG file at all. (Try opening it inside a text editor.)

这篇关于SVG不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆