背景设置的五个样式规则
1. 背景颜色: background-color
2. 背景图片: background-image
3. 背景图片的重复方式: background-repeat
4. 背景图片的定位方式: background-position
立即学习“前端免费学习笔记(深入)”;
5. 背景图片的的是否固定: background-attachment
6. 背景图片大小设置: 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>
以上就是CSS背景设置的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号