Search results
The background-attachment property sets whether a background image scrolls with the rest of the page, or is fixed. Browser Support. The numbers in the table specify the first browser version that fully supports the property. CSS Syntax. background-attachment: scroll|fixed|local|initial|inherit; Property Values. More Examples. Example.
- Background Attachment
CSS background-attachment. The background-attachment...
- Background Attachment
- Overview
- Syntax
- Examples
- Browser compatibility
The background-attachment CSS property sets whether a background image's position is fixed within the viewport, or scrolls with its containing block.
Values
fixed The background is fixed relative to the viewport. Even if an element has a scrolling mechanism, the background doesn't move with the element. (This is not compatible with background-clip: text.) local The background is fixed relative to the element's contents. If the element has a scrolling mechanism, the background scrolls with the element's contents, and the background painting area and background positioning area are relative to the scrollable area of the element rather than to the border framing them. scroll The background is fixed relative to the element itself and does not scroll with its contents. (It is effectively attached to the element's border.)
Simple example Multiple background images
This property supports multiple background images. You can specify a different for each background, separated by commas. Each image is matched with the corresponding type, from first specified to last.
BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
- as specified
- scroll
- no
Aug 23, 2024 · The background-attachment property sets whether a background image scrolls with the rest of the page or is fixed. It has three possible values: scroll (default, the image moves with content), fixed (image stays in place), and `local` (image scrolls within the element).
Learn how to use the CSS background-attachment property to specify whether the background image should scroll or be fixed. See examples, video and code snippets for different values of this property.
Learn how to use the CSS background-attachment property to control the scrolling behavior of background images. See examples of scroll, fixed, local, initial and inherit values.
The background-attachment property is used to specify that the background image is fixed or scroll with the rest of the page in the browser window. This property has three values scroll, fixed, and local. Its default value is scroll, which causes the element to not scroll with its content.
People also ask
What is background-attachment property in CSS?
What does the background-attachment property do?
How to attach background images in tailwind CSS?
Does a background image scroll?
Can a CSS property support multiple background images?
What is a background property in CSS?
Jun 6, 2017 · Learn how to use the background-attachment property in CSS to control how the background image moves with the viewport. See examples of scroll, fixed, and local values and their effects on the main and local views.