时间:2021-07-01 10:21:17 帮助过:59人阅读
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.gxlcms.com</a>)</h2>
</div>
</body>
</html>以上就是CSS背景设置的详细内容,更多请关注Gxl网其它相关文章!