Attribut Style backgroundAttachment
- Page précédente background
- Page suivante backgroundColor
- Retour au niveau supérieur Objet Style HTML DOM
Définition et utilisation
backgroundAttachment
Définit ou retourne si l'image de fond doit être défilée avec le contenu ou fixe.
Voir également :
Style HTML :Attribut background
Tutoriel CSS :Arrière-plan CSS
Manuel CSS :Attribut background-attachment
Exemple
Exemple 1
Définir l'image de fond en mode fixe (ne défile pas) :
document.body.style.backgroundAttachment = "fixed";
Exemple 2
Choisir scroll et local sur l'élément DIV :
document.getElementById("myDIV").style.backgroundAttachment = "local";
Exemple 3
Basculer entre scroll et fixed :
var x = document.body.style.backgroundAttachment; document.body.style.backgroundAttachment = (x == "scroll")? "fixed":"scroll";
Exemple 4
Retourner la valeur de l'attribut background-attachment :
alert(document.body.style.backgroundAttachment);
Syntaxe
Retourner la propriété backgroundAttachment :
object.style.backgroundAttachment
Définir la propriété backgroundAttachment :
object.style.backgroundAttachment = "scroll|fixed|local|initial|inherit"
Valeur de l'attribut
Valeur | Description |
---|---|
scroll | L'arrière-plan défile avec l'élément. Par défaut. |
fixed | L'arrière-plan est fixe par rapport à la fenêtre de visualisation. |
local | L'arrière-plan défile avec le contenu de l'élément. |
initial | Met cette propriété à sa valeur par défaut. Voir initial. |
inherit | Inherits cette propriété de son élément parent. Voir inherit. |
Détails techniques
Valeur par défaut : | scroll |
---|---|
Valeur de retour : | Une chaîne de caractères, indiquant comment l'image de fond est attachée à l'objet du document. |
Version CSS : | CSS1 |
Support du navigateur
backgroundAttachment
c'est une caractéristique de CSS1 (1996).
Tous les navigateurs le supportent intégralement :
Chrome | Edge | Firefox | Safari | Opera | IE |
---|---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera | IE |
Support | Support | Support | Support | Support | Support |
- Page précédente background
- Page suivante backgroundColor
- Retour au niveau supérieur Objet Style HTML DOM