offline version v3


86 of 298 menu

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 blur function
    that blurs a background
  • the brightness function
    that sets a background brightness
  • the contrast function
    that sets a background contrast
  • the drop-shadow function
    that sets a background shadow
  • the hue-rotate function
    that sets a background hue
  • the opacity function
    that sets a background opacity
  • the sepia function
    that converts a background to sepia
  • the background property
    that is a shorthand property for a background
  • the background-image property
    with that you can set a background image for a block
  • the filter property
    that sets a background style
enru