CSS opacity() Function
Example
Set various opacity for an image:
#img1 {
filter: opacity(80%);
}
#img2 {
filter:
opacity(50%);
}
#img3 {
filter: opacity(0.2);
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The CSS opacity()
filter function applies an
opacity effect to an element.
- 100% (or 1) will have no effect
- 50% (or 0.5) will make the element 50% transparent
- 0% (or 0) will make the element completely transparent
Version: | CSS Filter Effects Module Level 1 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
Function | |||||
---|---|---|---|---|---|
opacity() | 18 | 12 | 35 | 6 | 15 |
CSS Syntax
opacity(amount)
Value | Description |
---|---|
amount | Optional. Specifies the amount of opacity as a number or percent. 0% (or 0) will make the element completely transparent. 100% (or 1) represents the original image (no effect). Default value is 1. |
More Examples
Example
Use opacity() with the backdrop-filter property:
div.transbox {
background-color: rgba(255, 255, 255, 0.4);
-webkit-backdrop-filter: opacity(50%);
backdrop-filter:
opacity(50%);
padding: 20px;
margin: 30px;
font-weight: bold;
}
Try it Yourself »
Related Pages
CSS reference: CSS filter property.
CSS reference: CSS blur() function.
CSS reference: CSS brightness() function.
CSS reference: CSS contrast() function.
CSS reference: CSS drop-shadow() function.
CSS reference: CSS grayscale() function.
CSS reference: CSS hue-rotate() function.
CSS reference: CSS invert() function.