Home >Web Front-end >CSS Tutorial >How to set image tiling mode in css
In css, you can use the background-repeat attribute to set the image tiling method. When the value is "repeat", the background can be completely tiled. When it is "repeat-x", it can be tiled horizontally. When it is "repeat" -y" can be tiled vertically, and "no-repeat" can not be tiled (the image will only be displayed once).
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In css, you can use the background-repeat attribute to set the image tiling method.
The background-repeat attribute defines the tiling mode of the image and sets whether and how to repeat the background image.
The background-repeat attribute can set four tiling modes:
1. When the value is "repeat", the background can be completely tiled
repeat
: Default. The background image will repeat vertically and horizontally.
<!DOCTYPE html> <html> <head> <style> div { width: 500px; height: 500px; border: 2px solid red; background-image: url(img/nz.png); background-repeat:repeat; } </style> </head> <body> <div ></div> </body> </html>
2. When the value is "repeat-x", it can be tiled horizontally
repeat-x: Only the horizontal position will repeat the background image
div { width: 500px; height: 500px; border: 2px solid red; background-image: url(img/nz.png); background-repeat:repeat-x; }
3. When the value is "repeat-y", it can be tiled vertically
repeat-y: Only the vertical position will repeat the background image
div { width: 500px; height: 500px; border: 2px solid red; background-image: url(img/nz.png); background-repeat:repeat-y; }
4. When the value is "no-repeat", it will not be tiled
no-repeat: the background image will only be displayed once
div { width: 500px; height: 500px; border: 2px solid red; background-image: url(img/nz.png); background-repeat:no-repeat; }
(Learning video sharing: css video tutorial)
The above is the detailed content of How to set image tiling mode in css. For more information, please follow other related articles on the PHP Chinese website!