SVG for images in browsers with PNG fallback

后端 未结 6 1819
梦如初夏
梦如初夏 2020-12-13 14:24

I\'m looking to use SVG versions of a company logo on a website. At present, all current versions of major browsers (IE, Safari, Chrome, Firefox, Opera) support SVG, so this

6条回答
  •  清歌不尽
    2020-12-13 15:04

    I wouldn't call it the preferred way, but if you want to pursue your second option this should detect SVG support (from Raphaël 1.5.2):

    if(window.SVGAngle || 
        document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") {
        // supports SVG
    else {
        // no SVG
    }
    

    Raphaël uses this to determine if it should render using VML (IE) or SVG (everyone else).

    Out of curiosity, why SVG for your logo? If you already have a PNG version, this seems like a lot of work.

提交回复
热议问题