From 258ba7b4be62d8640477a3bd3146d08b00cb70ec Mon Sep 17 00:00:00 2001
From: julieng La propriété La propriété
There were doors all round the hall, but they were all locked; and when
Alice had been all the way down one side and up the other, trying every
door, she walked sadly down the middle, wondering how she was ever to
get out again.
-</p>background-attachment
définit si la position de l'image d'arrière-plan est fixée dans la zone d'affichage (viewport) ou si celle-ci défile avec le bloc englobant.Syntaxe
+## Syntaxe
-/* Valeurs avec un mot-clé */
+```css
+/* Valeurs avec un mot-clé */
background-attachment: scroll;
background-attachment: fixed;
background-attachment: local;
@@ -24,65 +25,69 @@ background-attachment: local;
background-attachment: inherit;
background-attachment: initial;
background-attachment: unset;
-
+```
-background-attachment
est définie avec un des mots-clés de la liste suivante.Valeurs
+### Valeurs
-
-
+- `fixed`
+ - : Ce mot-clé indique que l'arrière-plan est fixe par rapport à la zone d'affichage (_viewport_). Ainsi, même si l'élément dispose d'outils de défilement, l'arrière-plan ciblé ne se déplacera pas avec l'élément (cette valeur n'est pas compatible avec {{cssxref("background-clip", "background-clip: text", "#text")}}).
+- `local`
+ - : Ce mot-clé indique que l'arrière-plan se déplace avec le contenu de l'élément associé. Ainsi, si l'élément défile, l'arrière-plan défilera avec. Les zones de positionnement et de dessin de l'arrière-plan sont relatives à la zone de l'élément plutôt qu'au cadre extérieur.
+- `scroll`
+ - : Ce mot-clé indique que l'arrière-plan est fixé par rapport au contenu de l'élément (il ne défile pas avec) mais est rattaché à la bordure de l'élément.
-fixed
local
scroll
Syntaxe formelle
+### Syntaxe formelle
{{csssyntax}}
-Exemples
+## Exemples
-Exemple simple
+### Exemple simple
-CSS
+#### CSS
-p {
+```css
+p {
background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif");
background-attachment: fixed;
}
-
+```
-HTML
+#### HTML
-<p>
+```html
+
+
{{EmbedLiveSample("Exemple_simple")}}
+{{EmbedLiveSample("Exemple_simple")}} -On peut utiliser cette propriété lorsqu'on travaille avec plusieurs images en arrière-plan. On peut définir, pour chaque image, un background-attachment
spécifique. Pour cela, on utilisera une liste, séparée par des virgules. Les images seront associées dans l'ordre à chaque propriété d'attachement.
p { +```css +p { background-image: url("https://mdn.mozillademos.org/files/12057/starsolid.gif"), url("https://mdn.mozillademos.org/files/12059/startransparent.gif"); background-attachment: fixed, scroll; background-repeat: no-repeat, repeat-y; -}+} +``` -
<p> +```html +- -There were doors all round the hall, but they were all locked; and when Alice had been all the way down one side and up the other, trying every door, she walked sadly down the middle, wondering how she was ever to @@ -96,49 +101,27 @@ background-attachment: unset; time round, she came upon a low curtain she had not noticed before, and behind it was a little door about fifteen inches high: she tried the little golden key in the lock, and to her great delight it fitted! -</p>
{{EmbedLiveSample("Gestion_de_plusieurs_arrière-plans")}}
- -Spécification | -État | -Commentaires | -
---|---|---|
{{SpecName('CSS3 Backgrounds', '#the-background-attachment', 'background-attachment')}} | -{{Spec2('CSS3 Backgrounds')}} | -La propriété a été étendue pour gérer plusieurs arrière-plans et la valeur local . |
-
{{SpecName('CSS2.1', 'colors.html#propdef-background-attachment', 'background-attachment')}} | -{{Spec2('CSS2.1')}} | -Aucune modification significative. | -
{{SpecName('CSS1', '#background-attachment', 'background-attachment')}} | -{{Spec2('CSS1')}} | -Définition initiale. | -
{{cssinfo}}
- -{{Compat("css.properties.background-attachment")}}
- -