问题与MIME类型和服务SVG:资源跨$ PTED为图像,但MIME类型文本传输p $ / XML [英] Issue with MIME types and serving svg: Resource interpreted as Image but transferred with MIME type text/xml

查看:224
本文介绍了问题与MIME类型和服务SVG:资源跨$ PTED为图像,但MIME类型文本传输p $ / XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我针对一些SVG图像,CSS作为一些因素的背景使用,并且有一些奇怪的问题。当直接到图片它工作正常,但是当使用在CSS中,我得到了以下错误:

I'm targeting some SVG images with CSS to use as backgrounds on a few elements and having some strange issues. When going directly to the image it works fine, but when using in CSS I get the following error:

PTED为图像,但MIME类型文本传输资源跨$ P $ / XML

我添加了一个.htaccess文件,以供应用下面的code中的图像目录,但它并没有帮助:

I've added an .htaccess file to the directory that serves the images with the following code, but it didn't help:

AddType image/svg+xml svg

建议?

推荐答案

在可能的解释是,previously HTTP标头中指定了错误的内容类型,现在你有固定的,一些软件使用缓存的信息。 (并不少见当使用XML文件)。最简单的方法来检查其中的内容是创建.svg文件的副本,并使用新名称是指它在CSS。

The probable explanation is that previously the HTTP headers specified a wrong content type, and now that you have fixed it, some software uses cached information. (Not uncommon when using XML files.) The simple way to check things out is to create a copy of the .svg file and refer to it in CSS using the new name.

当我测试你在一个简单的背景给了规则的网址,图像显示无在Firefox,IE,Chrome浏览器,Safari浏览器的问题(在Win 7测试)。但是,当我测试这个让内容类型:text / xml的由服务器发送,所有的浏览器根本不显示背景图片;不会显示任何错误消息。所以,我想你有一些特殊的浏览器或具有特殊设置的测试。

When I test the URL you gave in a simple background rule, the image shows without problems on Firefox, IE, Chrome, Safari (tested on Win 7). But when I test this so that Content-Type: text/xml is sent by a server, all the browsers simply don’t show a background image; no error message is shown. So I suppose you tested with some special browser or with special settings.

这篇关于问题与MIME类型和服务SVG:资源跨$ PTED为图像,但MIME类型文本传输p $ / XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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