HTML/CSS/SVG: SVG background image in IE7/8

风格不统一 提交于 2019-12-13 04:01:44

问题


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


回答1:


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'); }


来源:https://stackoverflow.com/questions/12262973/html-css-svg-svg-background-image-in-ie7-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!