1.背景颜色的设置
background-color:设置背景的颜色(不能继承)
<div class="container">
</div>
<style>
.container{
width:400px;
height: 300px;
background-color: aqua;
}
</style>
2.背景图片的样式
background-image: url();
在url中写上图片的路径
.container{
width:800px;
height: 300px;
background-image: url("0.jpg");
}
background-repeat:repeat;背景平铺
此时 background-repeat:的默认值为no-repeat;
此时背景平铺了
background-repeat: no-repeat;背景不平铺
.container{
width:800px;
height: 500px;
background-image: url("0.jpg");
background-repeat: no-repeat;
border: 1px solid red;
}
background-repeat: repeat-x,水平平铺
.container{
width:800px;
height:500px;
background-image: url("0.jpg");
background-repeat:repeat-x;
border: 1px solid red;
}
background-repeat: repeat-y,纵向平铺
.container{
width:800px;
height:500px;
background-image: url("0.jpg");
background-repeat:repeat-y;
border: 1px solid red;
}
background-position: x y;调整图片的位置
.container{
width:800px;
height:500px;
background-image: url("0.jpg");
background-repeat:no-repeat;
border: 1px solid red;
background-position: 100px 100px;
}
此时图片的位置进行偏移了
background-position的属性值还有:
center
left
bottom
top