CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES

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:

background-attachment scroll | fixed | initial | inherit

The example below shows the background-attachment property in action.

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.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 3.5+

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.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties