invert function
The invert function allows you to
invert colors in a background image. The value
0 means that the image remains original. The
value of 100% or 1 completely
inverts the background colors. Any number
located in this range partially inverts
the colors. A negative value cannot be
specified. The default value is 0.
Syntax
selector {
filter: invert(number);
}
Example
Let's invert the colors of
our image to 50%:
<div id="elem"></div>
#elem {
filter: invert(50%);
background: url("bg.png") center / cover no-repeat;
width: 400px;
height: 300px;
border: 1px solid black;
}
:
Example
Now let's invert the colors of our image
to the value of 100%:
<div id="elem"></div>
#elem {
filter: invert(100%);
background: url("bg.png") center / cover no-repeat;
width: 400px;
height: 300px;
border: 1px solid black;
}
:
Example
Now let's set the invert function
to the value equal to 0:
<div id="elem"></div>
#elem {
filter: invert(0);
background: url("bg.png") center / cover no-repeat;
width: 400px;
height: 300px;
border: 1px solid black;
}
:
See also
-
the
blurfunction
that blurs a background -
the
brightnessfunction
that sets a background brightness -
the
contrastfunction
that sets a background contrast -
the
drop-shadowfunction
that sets a background shadow -
the
hue-rotatefunction
that sets a background hue -
the
opacityfunction
that sets a background opacity -
the
sepiafunction
that converts a background to sepia -
the
backgroundproperty
that is a shorthand property for a background -
the
background-imageproperty
with that you can set a background image for a block -
the
filterproperty
that sets a background style