CSS background-attachment property
Browser support · legacy reference
ChromeFully supports
SafariFully supports
FirefoxFully supports
Internet ExplorerFully supports
EdgeFully supports
OperaFully supports
Description
CSS background-attachment property represents the position of background image within a box. The position of box is specified with respect to both the viewport (visible area of web page) and the content within the box.
Please use the 'inner (box)' and 'outer (viewport)' scrollbars to understand and distinguish between these properties.
Syntax
background-attachment : fixed | scroll | local
Property values
fixedDefault
-
The background is fixed with respect to both the content box and the viewport.
-
The background-image remains fixed with respect to both the box and the viewport.
- Try it
background-attachment: fixed; scroll
-
The background remains fixed with respect to the content box but scrolls with respect to viewport.
-
The background-image remains fixed with respect to the content box but does not remain fixed with respect to viewport.
- Try it
background-attachment: scroll; local
-
The background does not remain fixed with respect to both the content box and the viewport.
-
The background-image scrolls with respect to both content box and viewport.
- Try it
background-attachment: local;
Applicable to
It applies to all elements