CSS 背景附着

CSS background-attachment

background-attachment 属性指定背景图像是应该滚动还是固定的(不会随页面的其余部分一起滚动):

实例

指定应该固定背景图像:

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

亲自试一试

实例

指定背景图像应随页面的其余部分一起滚动:

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

亲自试一试