mozilla
Your Search Results

    background-repeat

    Summary

    The background-repeat CSS property defines how background images are repeated. A background image can be repeated along the horizontal axis, the vertical axis, both, or not repeated at all. When the repetition of the image tiles doesn't let them exactly cover the background, the way adjustments are done can be controlled by the author: by default, the last image is clipped, but the different tiles can instead be re-sized, or space can be inserted between the tiles.

    Note: If the value of this property is not set in a background shorthand property that is applied to the element after the background-repeat CSS property, the value of this property is then reset to its initial value by the shorthand property.

    Syntax

    background-repeat: repeat-style[, repeat-style]*
    

    where:

    repeat-style
    Is following either the one-value syntax — and in that case the values are shorthand for ther two-value equivalent:
    repeat-x is the equivalent of repeat no-repeat
    repeat-y is the equivalent of no-repeat repeat
    repeat is the equivalent of repeat repeat
    space is the equivalent of space space
    round is the equivalent of round round
    no-repeat is the equivalent of no-repeat no-repeat
    Or the two-value syntax where the first value represents the horizontal behavior of the repetition and the second value the vertical behavior:

    repeat The image is repeated in the given direction as much as needed to cover the whole background image painting area. The last image may be clipped if the whole thing won't fit in the remaining area.
    space The image is repeated in the given direction as much as needed to cover most of the background image painting area, without clipping an image. The remaining non-covered space is spaced out evenly between the images. The first and last images touches the edge of the element. The value of the background-position CSS property is ignored for the concerned direction, except if one single image is greater than the background image painting area, which is the only case where an image can be clipped when the space value is used.
    round The image is repeated in the given direction as much as needed to cover most of the background image painting area, without clipping an image. If it doesn't cover exactly the area, the tiles are resized in that direction in order to match it.
    no-repeat The image is not repeated (and hence the background image painting area will not necessarily been entirely covered). The position of the non-repeated background image is defined by the background-position CSS property.

    Examples

    View the live example

    .exampleone {
      background-image: url("logo.png");
      background-repeat: repeat-x;
    }
    
    .exampletwo {
      background-image: url("logo.png");
      background-repeat: no-repeat;
    }
    
    .examplethree {
      background-image: url("img1.png"), url("img2.png");
      background-repeat: repeat-x, repeat-y;
    } 
    

    Each image is matched with the corresponding repeat style, from first specified to last.

    Specifications

    Specification Status Comment
    CSS Backgrounds and Borders Module Level 3 Candidate Recommendation Added support for multiple backgrounds images, the two-value syntax allowing distinct repetition behavior for the horizontal and vertical directions, the space and round keywords, and for backgrounds on inline-level element by defining precisely the background painting area.
    CSS Level 2 (Revision 1) Recommendation No significant changes
    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 (85)
    Multiple backgrounds 1.0 3.6 (1.9.2) 9.0 10.5 1.3 (312)
    Different values for X & Y directions (two-value syntax) (Yes) 13.0 (13.0) bug 548375 9.0 (Yes) (Yes)
    round and space keywords Not supported Not supported bug 548372 9.0 10.5 Not supported
    Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
    Basic support ? ? ? ? ?
    Multiple backgrounds ? ? ? ? ?
    Different values for X & Y directions (two-value syntax) ? ? ? ? ?
    round and space keywords ? ? ? ? ?

    See also

     

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

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