Re: [css3-background] Transparent background-image and fallbacks

2009/10/14 Erik Dahlstrom <ed@opera.com>:
> Hello www-style,
>
> I'm interested in using multiple background-images as fallbacks for when a
> particular image format isn't supported, as defined in [1].
>
> For my use-case it's fine as long as I use fully opaque images, but for a
> case where I have a transparent image on top and a different image as
> fallback (with slightly different shape) it doesn't work that well because
> I'd not want that fallback image visible at all if the first one was used.
>
> I was wondering if there was a way of detecting which images were actually
> used, because that would make it easy to fix UA issues by javascript.
> However, I note that the current spec wording doesn't deal with the cases
> where a particular url wasn't supported/used by the UA. Would it be possible
> to remove the url's that were not supported by the UA from the computed
> value of the 'background-image' property? That is essentially what happens
> to the display in such cases, and it would make such cases easy to detect.

You cannot know which images you support until you actually fetch them
(to get a Content-Type), much later computed value and inheritance
phase.

> Are there any other ways of detecting CSS background-image format support,
> or other ways of providing fallbacks for the case outlined above?

Yes:
image(one.svg, two.apng, three.gif, four.png or white);

(although there's some discussion about syntax)

defined in CSS Images Module Level 3 at
http://dev.w3.org/csswg/css3-images

> Cheers
> /Erik
>
> [1] http://www.w3.org/TR/css3-background/#the-background-image
>
> --
> Erik Dahlstrom, Core Technology Developer, Opera Software
> Co-Chair, W3C SVG Working Group
> Personal blog: http://my.opera.com/macdev_ed
>
>

Giovanni

Received on Wednesday, 14 October 2009 12:40:20 UTC