CSS background-attachment property
CSS

CSS background-attachment property

Mishel Shaji
Mishel Shaji

The background-attachment CSS property is used to set whether a background image’s position is fixed within the viewport, or scrolls with the page.

Syntax

background-attachment:fixed|scroll|initial|inherit|unset;

Values

fixedThe background image will not scroll
scrollThe background image will scroll with the element, not with the contents of the element.
localThe background image will scroll with the contents of the element.
inheritThe property is inherited from the parent element.

The default value is scroll.

Example – Fixed background image

Note: This may not work on some mobile devices.

The CSS background shorthand property can be used to specify all other background properties in a single declaration.