Web4College

CSS background-attachment property

src

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.

background-attachment: fixed;
Try it

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.

background-attachment: scroll;
Try it

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.

background-attachment: local;
Try it

Applicable to

It applies to all elements