CSS background-attachment
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The background-attachment
CSS property defines whether the background image scrolls with the document, or remains fixed to the viewing area.
The following table summarizes the usages context and the version history of this property
Default value: | scroll |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | No. See animatable properties. |
Version: | CSS 1, 2, 3 |
Syntax
The syntax of the property is given with:
The example below shows the background-attachment
property in action.
Example
Try this code »body {
background-image: url("images/recycle.jpg");
background-attachment: fixed;
}
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
scroll |
The default value. The background image is fixed with regard to the element itself and scroll within the viewport along with its containing element. |
fixed |
The background image is fixed with regard to the viewport and doesn't move with the element. |
local |
The background image stays fixed with regard to the element's contents: if the element has a scrolling mechanism, the background scrolls with the element's contents. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element background-attachment property. |
Browser Compatibility
The background-attachment
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Background, CSS3 Background.
Related properties: background
, background-color
, background-clip
, background-image
, background-origin
, background-position
, background-repeat
, background-size
.