-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS image()
function
#153
Comments
In the State of CSS 2022 question about browser incompatibilities, there was only a single mention of That response just named "image()", with no additional detail. |
I have a vague memory of a post from Tab some where saying that the working group wants |
In the MDN short survey on CSS & HTML, "CSS images ( Since this option bundled together multiple proposals we can't know what resonated, but given the State of CSS results I'm fairly certain it was mostly |
@tabatkins do you know? |
Thank you for proposing the CSS We wanted to let you know that this proposal was not selected to be part of Interop this year. We had many strong proposals, and could not accept them all. It was unclear if this is a major problem for web developers or users. If you uncover evidence that it is, resubmitting a proposal in the future would be welcome. For an overview of our process, see the proposal selection summary. Thank you again for contributing to Interop 2023! Posted on behalf of the Interop team. |
Description
The image() function allows an author to:
Rationale
spec fixes many long standing issues with CSS images:
a simplified syntax for image spriting that doesn't require 3 different CSS properties:
background-image: image('sprites.svg#xywh=40,0,20,20');
. This also opens up the use ofbackground-size
andbackground-position
for actual sizing and positioning of these images instead of dealing with the spriting.ability to create a solid color image like this:
background-image: image(red);
instead of hacking a gradient like this:linear-gradient(red, red)
. Is good for devs because it's less repetition in the code and for browser vendors i'm guessing this would allow a path to a separate algorithm for just rendering a solid colored image.Proper image fall-backs which url() can't do. When the image at the specified url can’t be downloaded or decoded, fallback to another image or color. This could lead to less background colors that are never seen being painted behind images.
automatically respect the image orientation specified in the image’s metadata.
FYI: the above are all from images-4 but the CSSWG is already looking at expanding image() in images-5 for things like background video and @image-manipulation
Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=703217
chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=254753#c_ts1639769079
webkit bug: https://bugs.webkit.org/show_bug.cgi?id=72584
(looks like in webkit and firefox a considerable amount of work was done but then was just abandoned?)
Specification
https://drafts.csswg.org/css-images-4/#image-notation
Tests
https://wpt.fyi/results/css/css-images?label=experimental&label=master&aligned&view=subtest
no tests yet for "Image Fragments" or "Bidi-sensitive Images"
only 5 tests right now all seems to be about "Solid-color Images" and "Image Fallbacks"
css-image-fallbacks-and-annotations.html
background: image("green.png", green);
css-image-fallbacks-and-annotations002.html
background-color: red;
background-image: image("support/1x1-green.png");
css-image-fallbacks-and-annotations003.html
background-image: image("1x1-green.svg", "support/1x1-green.png","support/1x1-green.gif");
css-image-fallbacks-and-annotations004.html
background-image: image("1x1-green.svg", "1x1-green.png", "support/1x1-green.gif");
css-image-fallbacks-and-annotations005.html
background-image: image(rgba(0,0,255,0.5)), url("support/1x1-green.png");
The text was updated successfully, but these errors were encountered: