By default, the background-image
property repeats an image both horizontally and vertically.
Some images should be repeated only horizontally or vertically, or they will look strange, like this:
If the image above is repeated only horizontally (background-repeat: repeat-x;
), the background will look better:
Tip: To repeat an image vertically, set background-repeat: repeat-y;
Showing the background image only once is also specified by the background-repeat
property:
Show the background image only once:
In the example above, the background image is placed in the same place as the text. We want to change the position of the image, so that it does not disturb the text too much.
The background-position
property is used to specify the position of the background image.
Position the background image in the top-right corner: