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
fixed | The background image will not scroll |
scroll | The background image will scroll with the element, not with the contents of the element. |
local | The background image will scroll with the contents of the element. |
inherit | The 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.