background-repeat
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.
Values
<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. |
Example
<!DOCTYPE HTML> <html> <head> <title>CSS Tutorials</title> <style> .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; } </style> </head> <body> <div class="exampleone"> first Div </div> <div class="exampletwo"> Second Div </div> <div class="examplethree"> THird Div </div> </body> </html>