XML technologies / CSS / Advanced websites with CSS / CSS property reference / background-attachment

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

The property background-attachment determines whether an HTML element’s background image moves up or down as the user scrolls, or is fixed at a position in the browser window and can thus be scrolled out of the visible browser area.

Inherited: no

See also: background-image

Values

fixed or scroll.

Default value: scroll

Compatibility

CSS version: 1

Supported by Internet Explorer 4 and later, Netscape 6 and later, Opera 5 and later, and all Mozilla versions.

Internet Explorer for Windows (up to version 6) and Opera (up to version 6) correctly support background-attachment: fixed only for the HTML element body. Opera 7, Internet Explorer 5 for Macintosh, Netscape 6.2.1 and later, and Mozilla support background-attachment for all HTML elements.

Example

The following rule assigns a background image to an HTML page and fixes it in place on the page:

body {
  background-image: url(/images/texture.gif);
  background-attachment: fixed;
}

  

 

 

 

back to top