If a background-image is specified, the background-attachment CSS property determines whether that image’s position is fixed within the viewport, or scrolls along with its containing block.
Initialscroll
Applies toall elements
Inheritedno
Mediavisual
Computed Valueas specified
Animatableno
Canonical orderthe unique non-ambiguous order defined by the formal grammar
Syntax
Formal syntax: <attachment>#
background-attachment: scroll
background-attachment: fixed
background-attachment: local
background-attachment: inherit
Values
scroll
This keyword means that the background image will scroll within the viewport along with the block the image is contained within.
fixed
This keyword means that the background image will not scroll with its containing element, instead remaining stationary within the viewport.
local
This keyword means that the background image will not scroll with its containing element, but will scroll when the element’s content scrolls: it is fixed regarding the element’s content.
Examples
1
body {
2
background-image: url("images/cartooncat.png");
3
background-attachment: fixed;
4
}
Multiple background image support
This property supports multiple background images. You can specify a different <attachment> for each background, separated by commas: