CSS BACKGROUND-ATTACHMENT

The background-attachment property sets whether a background image is fixed or scrolls with the rest of the page. The property denotes whether the background is fixed with regard to the viewport (fixed) or scrolls together with the containing block (scroll).

Note that even if the image is set as fixed, it will still only be visible when it is within the padding, content or border of the actual element. Therefore, unless the image is tiled using background-repeat, it could be set as invisible to the user.

Inherited: No

Example
1
2
3
4
body {
  background-image: url(stars.gif);
  background-attachment: scroll
}

Possible Values

scroll: The background image moves when the rest of the page scrolls
fixed: The background image does not move when the rest of the page scrolls.
local: The background image will not scroll with the containing element, but will scroll when the element’s content actually scrolls. So, it is fixed regarding the element’s content.