background
1,background-color 背景颜色
关键字(red,blue,yellow,green)
rgb()
十六进制 #000 #000000
2,background-image:url(图片路径); 背景图片
3,background-repeat:repeat(默认值) 背景图平铺
repeat-x (横轴平铺)
repeat-y (纵轴平铺)
no-repeat (不平铺)
4,background-position:x y 背景图位置
关键字 x y
left(居左) top(居顶)
right(居右) bottom(居底)
center(居中) center(居中)
数值:
x 从元素左侧向右移动的距离
y 从元素顶部向下移动的距离
background-position:50px;
显示的是:
background-position-x: 50px;
background-position-y: center;
百分比: 不推荐使用
background: #f1f2f2 url(img.gif) no-repeat 20px 20px;
5,background-attachment
scroll 随着滚动条滚动
fixed 不随着滚动条滚动
设置了fixed之后,图片位置会根据可视区的左上角来计算。