On Aug 5, 2014, at 6:15 PM, Philippe Wittenbergh <e...@l-c-n.com> wrote:

> 
> Le 6 août 2014 à 06:40, Karl DeSaulniers <k...@designdrumm.com> a écrit :
> 
>> urn your svg image into a base64 and load the image data as content: "". 
>> Wouldn't that work?
> 
> No, that wouldn't work any differently. A browser that doesn't support SVG 
> will see an invalid / unrecognised image format as content of the 
> background-image: url(); It will apply the rule (valid, recognised syntax) 
> but can't display the image. Because it recognises the syntax, it will not 
> fall back to the previous rule that references the .PNG image.
> 
> Philippe
> --
> Philippe Wittenbergh
> http://l-c-n.com/
> 

Ah yes, I guess you are right.
Hope you all don't mind, but I would say this is a javascript solution.
Check the browser for svg support and load the one you want.
Done.

SVG detection:  https://github.com/wout/svg.js/blob/master/src/svg.js#L67

function supportsSVG() {
        ...
}

VML: 
function supportsVml() {
    if (typeof supportsVml.supported == "undefined") {
        var a = document.body.appendChild(document.createElement('div'));
        a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
        var b = a.firstChild;
        b.style.behavior = "url(#default#VML)";
        supportsVml.supported = b ? typeof b.adj == "object": true;
        a.parentNode.removeChild(a);
    }
    return supportsVml.supported
}

...

if(supportsVML() || supportsSVG()) {
document.body.style.backgroundImage="url('img_tree.svg')";
} else {
document.body.style.backgroundImage="url('img_tree.png')";
}

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
______________________________________________________________________
css-discuss [css-d@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to