The background-attachment property specifies whether a background image scrolls with the element's box, is fixed relative to the viewport, or scrolls with the box's contents. With multiple comma-separated background layers, a value may be given per layer..hero {
background-attachment: fixed;
}.layered {
background-image: url('top.png'), url('bottom.png');
background-attachment: local, scroll;
}scrollThe background image is fixed to the element's box and scrolls along with it (default).fixedThe background image is fixed relative to the viewport and does not move when scrolling.localThe background image scrolls with the element's contents (when the element has its own scrolling).CSS Backgrounds Module Level 4First Public Working DraftW3CMDNCSSShow all codeEdit CSS onlineThe plugin that remembers hundreds of CSS items for youEvery CSS property — in a live demonstrationThe bilingual CSS referencedefinitionexamplessyntaxmodulespecificationsourcesvisual demonstrationpreviousnext