Home > Article > Web Front-end > How to set transparency in css
In CSS, transparency is set using the opacity property, ranging from 0.0 (fully transparent) to 1.0 (fully opaque). Syntax: opacity: ;
Transparency setting in CSS
In CSS, transparency is a property value, which Controls the element's transparency, ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
To set transparency, use the opacity
property. Its syntax is as follows:
<code>opacity: <opacity-value>;</code>
where <opacity-value>
is a numeric value representing the transparency of the element.
Example of setting transparency
For example, to set an element to 50% transparent, you can write:
<code class="css">element { opacity: 0.5; }</code>
Other notes
opacity
The opacity property applies to all HTML elements, including text, images, and shapes. opacity
property does not apply to canvas elements because their transparency is controlled by the globalAlpha
property. opacity
attribute is not supported. Transparency can be achieved using the filter
attribute instead. The above is the detailed content of How to set transparency in css. For more information, please follow other related articles on the PHP Chinese website!