HTML / CSS / SVG:IE7 / 8中的SVG背景图片 [英] HTML/CSS/SVG: SVG background image in IE7/8

查看:472
本文介绍了HTML / CSS / SVG:IE7 / 8中的SVG背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个我用作背景图片的SVG图片。我不工作在IE8及以下(如预期),我认为我可以使用类似的东西: http:/ /twostepmedia.co.uk/svgeezy/ http://code.google.com/ p / svgweb / 。但是,这些都不支持SVG作为背景图片/背景,只支持IMG和对象等。



代码:

  background:url('img / bck_hero.svg'); 

如何获取一个SVG作为背景在IE8 / 7或有一个后备图像?是否有可以执行此操作的JavaScript库?



非常感谢,



Harley

$一种方法是使用javascript检测对svg的支持,然后根据不同的样式使用不同的样式。



如果您使用 modernizr ,您可以在样式表中执行此操作:

 #myElm.svg {background:url('img / bck_hero.svg'); } 
#myElm.no-svg {background:url('img / bck_hero.png'); }


I have made an svg image that I am using as a background image. I does not work in IE8 and below (as expected), and I thought I could use something use like: http://twostepmedia.co.uk/svgeezy/ or http://code.google.com/p/svgweb/. However, none of these support SVG as a background-image/background, only IMG and Object etc.

Code:

background:url('img/bck_hero.svg');

How can I get an SVG as the background in IE8/7 or have a fallback image? Is there a javascript library that could do this?

Thanks a lot,

Harley

解决方案

One way is to detect support for svg with javascript and then style differently depending on that.

If you use modernizr you could do it like this in your stylesheet:

#myElm.svg { background:url('img/bck_hero.svg'); }
#myElm.no-svg { background:url('img/bck_hero.png'); }

这篇关于HTML / CSS / SVG:IE7 / 8中的SVG背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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