Home >Web Front-end >CSS Tutorial >CSS background settings
Five style rules for background settings
1. Background color: background-color
2. Background image: background-image
3. Repeating background images Method: background-repeat
4. How to position the background image: background-position
5. Whether the background image is fixed: background-attachment
6. Background image Size setting: background-size
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>2.CSS背景设置</title> <style> body { background-color: lightcyan; background-image: url(../images/bg/sky3-1.png); background-repeat: no-repeat; background-attachment:fixed; background-size: cover; } div { width: 300px; height: 200px; line-height: 100px; text-align: center; background-color: aquamarine; /*可以通过js等方式来设置背景色透明*/ /*background-color: transparent;*/ border: 1px solid #363636; } </style> </head> <body> <div> <h2>PHP中文网 (<a href="">www.php.cn</a>)</h2> </div> </body> </html>
The above is the detailed content of CSS background settings. For more information, please follow other related articles on the PHP Chinese website!