Chrome没有显示SVG文件 [英] Chrome not showing a SVG file

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

问题描述

我在HTML5文件中嵌入了SVG插图,当我在本地尝试使用SVG时,该样式在所有现代浏览器中都有效,但是当我尝试通过网络提供它们时,却没有让Chrome呈现SVG图像,而是仅呈现了SVG源代码.我已经将以下行添加到.htaccess文件中,该文件解决了Safari和Firefox中的问题:

I have a SVG ilustration embeded in an HTML5 file which works in all modern browsers when I try it on local, but when I try to serve them from the web I dont get Chrome to render the SVG image, it only renders the SVG source code. I already added this lines to an .htaccess file which solved the issues in Safari and Firefox:

AddType image/svg+xml svg
AddType image/svg+xml svgz
AddEncoding x-gzip .svgz

但是,Chrome现在是唯一一个不显示来自网络的图像的浏览器. 即使在Chrome中,我的本地文件也可以正常工作.

But Chrome now is the only browser that doesn't render the image when comes from the web. My local file works fine even in Chrome.

我想念什么?

这里是问题样本的链接,请在Safari和Firefox上尝试一下,它将起作用.但是在Chrome中,情况就不同了.

Here is the link to the sample of the issue, try it on Safari and Firefox, it will work. But in Chrome the story is different.

链接已断开,似乎缺少www.字首: http://www.getformgallery.com/demo/gos-form.html

Link was broken and seems to be missing www. prefix: http://www.getformgallery.com/demo/gos-form.html

推荐答案

我有同样的问题.在某些Chrome更新之前,我在网站上使用的svg可以正常工作,但是从某些Chrome更新开始,这些svg无法正常工作,也无法加载页面,只能加载1-2秒,然后重定向到Aw,很快.

I have the same problem. Before some Chrome updates the svg I used in my site works but from certain Chrome updates those svg didn't worked and the page won't load either, just loads for 1-2s and then redirected to Aw, snap.

最后我弄清楚了.您必须在对象标签中定义宽度"和高度" 例如.

Finally I figure it out. You have to define "width" and "height" in Object tag eg.

<object height="100%" width="100%"data="images/image.svg" type="image/svg+xml"></object>

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

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