You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: files/en-us/web/css/filter-function/invert/index.md
+110-9Lines changed: 110 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,31 +43,132 @@ filter: invert(1);
43
43
## Syntax
44
44
45
45
```css
46
-
invert(amount)
46
+
/* No inversion */
47
+
invert(0)
48
+
49
+
/* Complete inversion */
50
+
invert()
51
+
invert(1)
52
+
invert(100%)
53
+
54
+
/* 60% inversion */
55
+
invert(.6)
56
+
invert(60%)
47
57
```
48
58
49
59
### Parameters
50
60
51
-
-`amount` {{Optional_Inline}}
52
-
- : The amount of the conversion, specified as a {{cssxref("<number>")}} or a {{cssxref("<percentage>")}}. A value of `100%` is completely inverted, while a value of `0%` leaves the input unchanged. Values between `0%` and `100%` are linear multipliers on the effect. The initial value for {{Glossary("interpolation")}} is `0`. The default value is `1`.
61
+
-{{cssxref("<number>")}} or {{cssxref("<percentage>")}} {{Optional_Inline}}
62
+
- : Specifies the amount of the conversion. A value of `100%` is completely inverted, while a value of `0%` leaves the input unchanged. Values between `0%` and `100%` are linear multipliers on the effect. The initial value for {{Glossary("interpolation")}} is `0`. The default value is `1`.
53
63
54
64
## Formal syntax
55
65
56
66
{{CSSSyntax}}
57
67
68
+
## SVG filter
69
+
70
+
The SVG {{SVGElement("feComponentTransfer")}} filter element can also be used to invert content by creating equivalent inversion on nested {{SVGElement("feFuncR")}}, {{SVGElement("feFuncG")}}, and {{SVGElement("feFuncB")}} table elements. We set the same `tableValue` for the red, green, and blue filter primitives to the same value, then we can reference the SVG effect by the ID of the {{SVGElement("filter")}}:
71
+
72
+
```html
73
+
<svgrole="none">
74
+
<filterid="invert90">
75
+
<feComponentTransfer>
76
+
<feFuncRtype="table"tableValues="0.1 0" />
77
+
<feFuncGtype="table"tableValues="0.1 0" />
78
+
<feFuncBtype="table"tableValues="0.1 0" />
79
+
</feComponentTransfer>
80
+
</filter>
81
+
</svg>
82
+
```
83
+
84
+
The following declarations produce the same effect:
This example shows three images for comparison: an image with an `invert()` filter function applied, an image with the equivalent SVG function applied, and the original image:
96
+
97
+
### SVG
98
+
99
+
We create an SVG filter that inverts the content on which it is applied by 70%:
100
+
101
+
```html
102
+
<svgheight="0">
103
+
<filterid="invert">
104
+
<feComponentTransfer>
105
+
<feFuncRtype="table"tableValues="0.3 0" />
106
+
<feFuncGtype="table"tableValues="0.3 0" />
107
+
<feFuncBtype="table"tableValues="0.3 0" />
108
+
</feComponentTransfer>
109
+
</filter>
110
+
</svg>
111
+
```
112
+
113
+
### CSS
114
+
115
+
We include CSS that will invert elements based on their `filter` or `svgFilter` class:
0 commit comments