CSS background-attachment Property
Description
The background-attachment
property determines whether the background image will scroll along with the contents of the element. The image can be fixed and remain motionless, or move together with the document. You can specify multiple values for a series of background images, listing the values separated by commas.
- Initial value
- scroll
- Applies to
- All elements
- Inherited
- No
- Computed value
- As specified
- Animatable
- No
- JavaScript syntax
- object.style.backgroundAttachment
Interactive Demo
Syntax
background-attachment: <attachment> [ , <attachment> ]*
Values
<attachment> = scroll | fixed | local- scrollBackground image scrolls with the object as the document is scrolled.
- fixedBackground image will not scroll with its containing element, instead remaining stationary within the viewport.
- localBackground image will not scroll with its containing element, but will scroll when the element's content scrolls: it is fixed regarding the element's content.
- inherit
Example
<p>Example of the css background-attachment property.</p>
body {
background-image: url(images/diamond.png);
background-attachment: fixed;
height: 500px;
}
p {
padding: 10px;
background: white;
color: black;
}
Browser Support
The following table will show you the current browser support for the CSS background-attachment
property.
Desktop | |||||
12 | 1 | 1 | 3.5 | 1 |
Tablets / Mobile | |||||
18 | 4 | 10.1 | 3.2 | 1 | 37 |
Last updated by CSSPortal on: 1st January 2024