一、设置背景颜色:background-color
十六进制 background-color:#ff0000;
英文名称 background-color:red;
三原色 background-color:rgb(255,0,0)
transparent background-color:transparent;透明
二、设置背景图片:
1.引入背景图片:background-image
URL background-image:url("bg.jpg")
none 不设置背景图片
2.设置背景图片的平铺方式:background-repeat
repeat 将背景图案填满整个背景。
repeat-x 将背景图案在水平方向添满
repeat-y 将背景图案在垂直方向添满。
no-repeat 图案只出现一次。
3.设置背景图片的位置:background-position
top left 设置背景图案出现在上左方。
top center 设置背景图案出现在上方中间。
top right 设置背景图案出现在上右方。
center left 设置背景图案出现在中间左方。
center center 设置背景图案出现在IE中间。
center right 设置背景图案出现中间右方。
bottom left 设置背景图案出现在下左方。
bottom 设置背景图案出现在正下方。
bottom right 设置背景图案出现在下右方。
也可以通过坐标准确的定位图片的位置(x,y) x水平方方向的位置 y垂直方向的位置,单位是像素(px)
4.设置背景图像是否会随视窗滚动而滚动:background-attachment
scroll 设置背景图像会随视窗滚动条的移动而移动(默认)。
fixed 设置背景图像不会随视窗滚动条的移动而移动。
背景图案简化格式:颜色 背景图片 repeat attachment position