Css/Properties/background-attachment

From W3C Wiki

background-attachment

The background-attachment property specifies whether a background image is fixed with regard to the viewport or scrolls along with the containing block.

Description

Values scroll | fixed | inherit
Initial value scroll
Applies to All elements
Inherited No


Point, Note

  • Only when the background image is specified, this property is effective.


Values

  • scroll
    If specified, the background image scrolls with the element.


  • fixed
    If specified, the background image does not scrolls with the element.


  • inherited


Example

Example A

[style.css]

 body {
   background-image: url("images/bg.png");
   background-position: bottom right;
   background-attachment: fixed;
   background-repeat: no-repeat;
 }


CSS Reference

The CSS specification defines the background-attachment property in 14.2.1 Background properties.