Home >Web Front-end >CSS Tutorial >How to reduce background transparency in css
Css method to reduce background transparency: 1. Use the opacity attribute, just set the "opacity: transparency value;" style to the background element; 2. Use the filter attribute, just set the "filter" style to the background element : opacity (transparency value);" style.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css Reduce background transparency
Method 1: Use the opacity attribute
Opacity attribute to set one Element's transparency level. From 0.0 (fully transparent) to 1.0 (fully opaque)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> #box{ width: 300px; height: 300px; background-color: red; opacity: 0.4; } </style> </head> <body> <div id="box"></div> </body> </html>
Method 2: Use the filter attribute
The filter attribute is defined The visual effects of the element (e.g. blur and saturation).
opacity(%) can 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.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> #box{ width: 300px; height: 300px; background-color: red; filter: opacity(0.3); } </style> </head> <body> <div id="box"></div> </body> </html>
(Learning video sharing: css video tutorial)
The above is the detailed content of How to reduce background transparency in css. For more information, please follow other related articles on the PHP Chinese website!