Attachment ng Background ng CSS

CSS background-attachment

background-attachment The attribute specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page):

Example

Specify that the background image should be fixed:

body {
  background-image: url("tree.png");
  background-repeat: no-repeat;
  background-position: right top;
  background-attachment: fixed;
}

Try It Yourself

Example

Specify that the background image should scroll with the rest of the page:

body {
  background-image: url("tree.png");
  background-repeat: no-repeat;
  background-position: right top;
  background-attachment: scroll;
}

Try It Yourself