English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
CSS background-attachment Attribute defines whether the background image scrolls with the document or remains fixed in the viewing area.
The following table summarizes the usage context and version history of this attribute
Default Value: | scroll |
---|---|
Applicable To: | All Elements |
Inheritance: | None |
Animatable: | No.Please see Animation Attribute. |
Version: | CSS 1,2,3 |
JavaScript Syntax: | object object.style.backgroundAttachment="fixed" |
The syntax of this attribute is as follows:
background-attachment: scroll | fixed | initial | inherit
The following examples demonstrate how to use background-attachment Attribute.
body { background-image: url("images/recycle.jpg");background-attachment: fixed;}Test See‹/›
The following table describes the values of this attribute.
Value | Description |
---|---|
scroll | Default value. The background image is fixed relative to the element itself and scrolls with the elements contained in the viewport. |
fixed | The background image is fixed relative to the viewport and does not move with the element. |
local | The background image remains fixed relative to the element's content: if the element has a scrolling mechanism, the background scrolls with the element's content. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts its parent element's background-Computed Value of the attachment Attribute. |
background-Browser Compatibility of the attachment Attribute, all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS Background,CSS3Background.
Related Attributes:background,background-color,background-clip,background-image,background-origin,background-position,background-repeat,background-size.