CSS background-attachment properties

the background-attachment properties in CSS used for how to set background images’ position are fixed, scroll, within viewpoint, move background relative to the viewpoint or scrolls with its containing div or block.

Background-attachment properties value-


therefore, background-attachment value fixed is used for the element has a scrolling but the background does not move with the element to relative to the viewpoint.


therefore, in scroll value, the background is fixed relative to the element itself and it does not scroll with its contents. (therefore, It is effectively attached to the element’s border.)


consequently, in the local value, the background is fixed relative to the element’s contents.

If the content has a scrolling mechanism, the background scrolls with the element’s contents and background therefore, positioning area is relative to the scrollable area of the element else to the border framing them.