背景属性可以设置为背景的颜色,图片,平铺,图片位置,图像固定。
背景颜色
background-color:#535759; /*颜色为棕色*/
background-color:transparent; /*透明颜色*/
背景图片
background-image属性描述了元素的背景图像。实际开发中常用于loge或者一些装饰性小图片或则超大的背景图片。优点是便于控制图片位置。
background-image :none/url /*none是没有背景图片,而url是图片链接*/
背景平铺
background-repeat属性。
background-repeat : repeat/no-repeat/repeat-x/repeat-y
/*repeat 平铺,no-repeat不平铺 ,repeat-x沿着x轴平铺,repeat-y沿着y轴平铺*/
背景图片位置
background-position属性
background-position:x y;
/* x y 坐标,可以使用方位名词,或者精确单位*/
如果两个都是方位名词,则两个词的顺序无关,
如果指定一个方位名词,则第二个默认居中对齐。
如果是精确单位,那么第一个是x坐标,第二个是y坐标。
如果精确单位只指定一个数值,那一定是x坐标,第二个默认居中。
背景图像的固定
background-attachment属性设置背景图像是否固定或者随着页面的其余部分滚动。
scroll | 背景图像随对象内容而滚动 |
fixed | 背景图像固定 |