CSS invert() Function
invert() function to invert the samples in an image.
invert() function is used with the
filter property to invert the samples in an image.
invert() function requires an argument to be passed to it. This argument determines the proportion of the conversion that's applied to the image. The argument can be either a percentage value or a number.
Here's an example using a percentage value to make an image completely inverted:
Here's an example using a percentage value to make the image partially inverted:
Here's an example using a number:
The official syntax of the
invert() function is as follows:
invert() = invert( [ <number> | <percentage> ] )
invert() function accepts a
<percentage> as its argument. This argument determines the proportion of the conversion.
A value of
100% results in an image that's completely inverted. A value of
0% results in an image that's unchanged. Values between
100% are linear multipliers on the effect.
The specification allows amounts over
100%, but this will have no further effect on the image (i.e. the user agent will clamp it to
<number> value of
0.5 has the same effect as the
50%. A value of
1 is the same as
Negative values are not allowed.
The following table provided by Caniuse.com shows the level of browser support for this feature.