Open thebabydino opened 2 months ago
what's the situation with filters like blur()
where the area that the component visually takes up changes? would it clip to the box of the element (like backdrop-filter
) or would it continue to expand the element (like filter
)?
what's the situation with filters like
blur()
where the area that the component visually takes up changes? would it clip to the box of the element (likebackdrop-filter
) or would it continue to expand the element (likefilter
)?
No overflow, it's clipped.
Super cool !!!!
Another use case for this would be to fix gradient banding using noise/ grain/ dither.
I just wanted to add a +1 and say that I had this exact use-case this week: I wanted to apply opacity to a background image (without having to mess around with using overlayed generated content instead).
Description
This allows us to apply a filter to an image before it's used as a
background-image
orborder-image
.It has been in Safari for almost a decade now, but no other browser has followed. Basic test.
Even in Safari, it doesn't work for CSS gradients - 🪲 250303.
Sometimes we only want to apply a filter on an element's
background-image
orborder-image-source
, but not to the entire element.For example, we may want to make a
background-image
semitransparent. Withfilter()
, this is as simple as:Live demo (Safari only).
Otherwise, we have to create an absolutely positioned pseudo-element that covers its entire parent, move it behind any text content we may have. Finally we need to make the pseudo-element semitransparent. More code, plus we're using up a pseudo-element that we might need for something else.
Similarly, we may want to selectively desaturate a
background-image
. That is, considering ourbackground-image
is one with red roses we want an effect like that of thegrayscale
filter on everything but the red of the rose petals. Again, this is one line of CSS withfilter()
(live demo, Safari only), but we need to resort to a pseudo otherwise.Things get a bit more complicated when we want that pseudo to have a filtered image background layer which then gets blended with another background layer of the same pseudo and finally, the whole pseudo itself has a
filter
applied. This is the case if, starting from a random image, we want to turn it into its grayscale halftone dots version.Live demo, Safari only. Without
filter()
, we'd need an extra element to achieve the same result.Another situation is when we only want to a apply a filter to the
border-image-source
. For example, let's say we want the spaced out (with a padding area gap)border
of an image to be a gradient that seems extracted out of the image palette.img
elements can't have::before
/::after
pseudos, so a nofilter()
solution would involve a wrapper. Withfilter()
, we can do this by applying a large blur on theborder-image-source
and then an alpha correction. Live demo, Safari only.Specification
Filter Effects Module Level 1
Additional Signals
No response