-
Notifications
You must be signed in to change notification settings - Fork 636
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-backgrounds] Add background-opacity
as an alternative to Relative Color (Color Module Level 5)
#8465
Comments
Just to comment on one point:
Actually no, looking at the results Safari has 100% passes (2076 / 2076) on RCS in the WPT tests, Chrome and Firefox are also working on it. It is also pre-cleared (before CR) as ready to ship Your example shows that RCS is pretty simple although there is no need to use
what happens if another stylesheet does :root {
--c-primary: color(display-p3 0 1 0);
} You may be assuming that the color space used for the declaration and the one used for RCS have to match? If so, rest assured that they do not. Although your example will still work, there will just be rgb values greater than 1 00% or less than 0. Either way, this seems like a simple and easy way to alter the alpha value. Your example is not demonstrating the complexity you mention, do you have a better example? |
In your proposal, would the alpha of the color and the background opacity get multiplied together? Is this (group) opacity, or an additional alpha value? |
background-opacity
as an alternative to Relative Color (Color Module Level 5)background-opacity
as an alternative to Relative Color (Color Module Level 5)
Another way to achieve this would be via image manipulation as discussed in #6807.
or like this: :root {
--c-primary: #e2273c;
}
.regular-background {
background: image(color(var(--c-primary)), opacity(0.5));
} Two big benefits of that approach:
Having said all that, this issue is actually a duplicate of #4996. So I close it in favor of the other one. Sebastian |
Safari has it under Experimental feature which mean it will probably not ship in the next stable release.
I'm not sure what you mean here. You copy pasted the same code block.
I don't know what you mean, this exemple was not part of my proposal.
I don't know, it would be up to working group to decide, it doesn't matter for me as I would never use it that way. |
But that would prevent you from using
That ticket hasn't seen any update in 3 years.
I feel like much more HTML elements should be pseudo-element instead of unstylable HTML Shadow. |
Nor would the property you propose. Though Safari passing all the tests is a good indicator that their implementation is ready to ship. Having said that, @svgeesus, https://bugs.webkit.org/show_bug.cgi?id=245970 indicates that the WPT tests don't cover system colors or
I guess, @svgeesus' point is that you proved with your example that your claim that the relative color syntax is "pretty complex" isn't true. And the note regarding
No, you could still use them together. The point is just that the opacity is only applied to the background image and not the color. The example defines a color as image and changes its opacity. The
Even when there wasn't any activity for years, it is still about the same topic. And you're welcome to add your comments there to revive the discussion. A pseudo-element might still be a possible solution for several use cases. Though the use case you outlined for making background colors transparent is already solved via the relative color syntax. And background image transparency (and much more) can be achieved with what I mentioned. The main point why I am against introducing a Approaches that introduce new value syntaxes like the relative color syntax or the image manipulation syntax are far more flexible and cover much more use cases. That comes with the cost of having to write a bit more. Sebastian |
Currently, it's impossible to change to opacity of a CSS Custom Propriety without:
a) Wacky hacks with Custom Proprieties
b) Relative Colors from CSS Color Module Level 5 which is unsupported by all browser and pretty complex.
c) Pseudo-elements nesting
Let's say I have this variable on my site.
But somewhere else I need to use this color variable but with opacity:
Option A
I could use an intermediate CSS Cutom Propriety, but it's hacky and it would require me to wrap my var in a rgb function for every use:
Option B
Using relative color from CSS Color Module Level 5
Option C
Proposal
On the plus side, this could also affect
background-image
which currently require to use Option C and a pseudo-element to change their opacity.From my very little understanding of how browser engine work, this seem a lot easier to implement than Relative Color and could be implement and shipped much faster.
The text was updated successfully, but these errors were encountered: