1.背景色
使用 background-color屬性爲元素設置背景色
如果希望背景色從元素中的文本向外少有延伸,只需增加一些內邊距
<style type = "text/css">
p{
background-color: rgb(0,255,255);
padding:20px;
}
</style>
顏色表達的方式:
rgb(1,1,1)
#00ffff
red(提供的常量)
可以爲所有元素設置背景色,默認值爲transparent:透明,
2.背景圖像
使用background-image屬性。默認值爲none
<style type = "text/css">
body{
background-image: url("./img/2.png");
}
</style>
3.背景重複
background-repeat
4.背景定位
background-position :center;
5.背景關聯
background-attachment :fixed;