CSS的背景

背景属性可以设置:背景颜色、背景图片、背景平铺、背景图片位置、背景图像固定等。

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

<style>
.div1 {
width: 400px;
height: 260px;
display: inline-block;
background-color: pink;
}

.div2 {
width: 400px;
height: 260px;
display: inline-block;
background-image: url(../新建文件夹/re0.jpg);
background-repeat: repeat;
}

.div3 {
width: 400px;
height: 260px;
display: inline-block;
background-color: rgb(112, 105, 106);
background-image: url(../新建文件夹/re0.jpg);
background-repeat: no-repeat;
/* background-position: left bottom; */
/* background-position: 50px 80px; */
/* background-position: 50% 50%; */
background-position: 2em 6em;
}

.div4 {
width: 1920px;
height: 1080px;
background-color: rgb(112, 105, 106);
background-image: url(../新建文件夹/1.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
</head>

<body>
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
<div class="div4"></div>
</body>

</html>