In this section, we will learn what the background-attachment property is and how to use it in CSS.
CSS background-attachment Property Definition and Usage
When we set an image for the background of an element, if we scroll the page, both element and its image will scroll together.
But CSS provided a property named `background-attachment` by which we can stop the background image of an element from scrolling if we scrolled its element (still the element itself scroll but not its background image).
CSS background-attachment Property Syntax
CSS background-attachment Property Value
The values for `background-attachment` property are:
- fixed: using this value, the background image of an element will stop scrolling.
- scroll: This is the default value and, if used, the background image of an element will scroll along its element.
- local: Using this value, the background image will scroll as the content within the element scrolled.