(一)background
1、background-imge:背景图片
基本用法:
(1)本地图片:background-imge:url('图片地址')
(2)在线图片
background-imge:url(./../imge:背景图片)
2、背景平铺:background-repeat
(1)background-repeat:repeat (默认)平铺(水平和垂直方向都重复)
(2)background-repeat:no-repeat 不平铺
(3)background-repeat repeat-y 垂直方向平铺
(3)background-repeat repeat-x 水平方向平铺
3、图片定位:background-position
(1)取值有两个值:第一个值代表水平方向偏移量、第二个代表垂直方向的偏移量
(2)后面取值:
a、填写像素数值
b、 垂直方向:
left right center
水平方向:
top bottom center
只输入left/right,第二个值默认center
(3)百分比
居中:background-position:50%
右下角:background-position:100% 100%
4、背景颜色:background-color
背景颜色取值方法:
a、十六进制(#ffffff)
b、RGB制
c、英文单词
5、background复合属性只复合:背景、背景平铺、图片定位、颜色
例:background:red==
background-imge:none;
background-repeat:repeat;
background-position:center;
background-color:red;
6、背景图片大小:background-size:width height
(1)可使用值:
a、像素; b、百分比;
c、系统提供的值:
cover:保持图像本身的宽高比例,将图片缩放到正好完全覆盖定义背景的区域;某些部分也许无法显示在背景定位区域中。
contain:把图像图像扩展至最大尺寸,以使其宽度和高度完全适应内容区域。
(2)只设置一个值,第二个值默认(auto——自动适配:原有比例缩放)【后面auto可以省,前面auto不能省】
7、背景图片滚动:background-attachment:
取值:scroll:会随着页面滚动条移动
fixed:固定图片,不会随着页面滚动条移动