Opacité du style Propriété
Exemple
Rendre un élément DIV transparent :
document.getElementById("myDIV").style.opacity = "0.5";
Définition et utilisation
La propriété opacity définit ou renvoie le niveau d'opacité d'un élément.
Le niveau d'opacité d'un élément décrit le niveau de transparence, où 1 n'est pas transparent du tout, 0,5 est transparent à 50 % et 0 est complètement transparent.
Prise en charge du navigateur
Property | |||||
---|---|---|---|---|---|
opacity | Yes | Yes | Yes | Yes | Yes |
Remarque : IE8 et les versions antérieures prennent en charge une alternative, la propriété filter.
Syntaxe
Renvoie la propriété d'opacité :
object.style.opacity
Définissez la propriété d'opacité :
object.style.opacity = "number|initial|inherit"
Valeurs de propriété
Value | Description |
---|---|
number | Specifies the opacity. From 0.0 (fully transparent) to 1.0 (fully opaque) |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Détails techniques
Valeur par défaut: | 1 |
---|---|
Valeur de retour : | Une chaîne, représentant le niveau d'opacité d'un élément |
Version CSS | CSS3 |
Pages connexes
Référence CSS : propriété d'opacité
❮ Objet de style