Home>Article>Web Front-end> How to set the transparency of images in css
How to set image transparency in css: 1. Use the filter attribute to add the "filter:opacity(value%)" style to the image element; the value is between 0 and 100, and "0%" is completely transparent. , "100%" means there is no change in the image. 2. Use the opacity attribute, the syntax "opacity: value".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Method 1: Use the filter attribute--filter:opacity(%)
The filter attribute defines the visibility of the element (usually) Effects (e.g. blur and saturation).
opacity(%): used to convert the transparency of the image. The value defines the scale of the conversion. A value of 0% means complete transparency, a value of 100% means no change to the image. Values between 0% and 100% are linear multipliers of the effect, equivalent to multiplying the number of image samples. If the value is not set, the value defaults to 1. This function is very similar to the existing opacity attribute, except that through filter, some browsers provide hardware acceleration to improve performance.
Example:
原图:
透明度为50%:
透明度为20%:
Rendering:
##Method 2: Use the opacity attribute
The Opacity attribute sets the transparency level of an element. Range of values: from 0.0 (fully transparent) to 1.0 (fully opaque). Example:Rendering:原图:
透明度为0.5:
透明度为0.2:
css video tutorial)
The above is the detailed content of How to set the transparency of images in css. For more information, please follow other related articles on the PHP Chinese website!