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

查看:64
本文介绍了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>

当我使用

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

它有效.但是,当我将该确切文件保存到我自己的服务器上并如上引用它时,它只显示 Firefox 中的后备文本.在 Chrome 中,它会在我打开页面时下载文件(证明文件链接正确).

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?

推荐答案

我能想到四种可能:

  1. 您的服务器对 SVG 图像使用了错误的 MIME 类型.(可以通过将 AddType image/svg+xml svg 添加到您的 .htaccess 文件来修复;此处讨论的其他方法)

  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)

您将 SVG 文件保存在其他位置,但 icons/chrome.svg 中不存在该文件.(尝试直接导航到位于 icons/chrome.svg 的 SVG 文件.它是否显示在您的浏览器中?)

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?)

您保存文件的权限不足,导致您的 Web 服务器无法访问该文件.(可以通过导航到 icons 目录并在命令行提示符下键入 chmod 0644 chrome.svg 来修复.)

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.)

您从 nocookie.net 下载的文件实际上根本不是 SVG 文件.(尝试在文本编辑器中打开它.)

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天全站免登陆