mozilla
Your Search Results

    background-attachment

    Summary

    If a background-image is specified, the background-attachment CSS property determines whether that image's position is fixed within the viewport, or scrolls along with its containing block.

    Syntax

    background-attachment:  http://i9.glitter-graphics.org/pub/48/48169s2581xo4hz.gif[, attachment]*
    

    where:

    attachment
    Is a keyword that can have one of the following values:
    • scroll, meaning that the background image will scroll within the viewport along with the block the image is contained within.
    • fixed, meaning that the background image will not scroll with its containing element, instead remaining stationary within the viewport.
    • local, meaning that the background image will not scroll with its containing element, but will scroll when the element's content scrolls: it is fixed regarding the element's content.

    Examples

    View the live example

    body {
      background-image: url("images/cartooncat.png");
      background-attachment: fixed;
    }
    

    Multiple background image support

    This property supports multiple background images. You can specify a different <attachment> for each background, separated by commas:

    body {
      background-image: url("img1.png"), url("img2.png");
      background-attachment: scroll, fixed;
    }

    Each image is matched with the corresponding attachment type, from first specified to last.

    Specifications

    Specification Status Comment
    CSS Backgrounds and Borders Module Level 3 Candidate Recommendation The shorthand property has been extended to support multiple backgrounds and the local value.
    CSS Level 2 (Revision 1) Recommendation No significant change.
    CSS Level 1 Recommendation  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 1.0 1.0 (1.7 or earlier) 4.0 3.5 1.0
    Multiple backgrounds 1.0 3.6 (1.9.2) 9.0 10.5 1.3
    local 4.0 Not supported 9.0 10.5 5.0
    Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
    Basic support 2.1 1.0 (1.9.2) ? 10.0 3.2
    Multiple backgrounds 2.1 1.0 (1.9.2) ? 10.0 3.2
    local ? Not supported ? ? ?

    See also

    Метки документа и участники

    Contributors to this page: teoli, paradox
    Обновлялась последний раз: teoli,
    Скрыть боковую панель