背景有关的属性
属性 | 作用 | 属性值 |
---|---|---|
background-color | 背景颜色 | 预定义的颜色值 / 十六进制码 / RGB代码 |
background-image | 背景图片 | url(“图片的路径”) |
background-repeat | 是否平铺 | repeat / no-repeat / repeat-x / repeat-y |
background-position | 背景位置 | length / position 分别填入x y坐标 |
background-attachment | 背景附着 | scroll(背景滚动) / fixed (背景固定) |
背景半透明 | 背景的颜色半透明化 | background:rgba(0,0,0,0.3); (一定得有四个值) |
背景简写 | 使代码变得更简单 | 背景颜色,背景图片地址,背景平铺,滚动/固定,背景位置 |
"background-position"
他用于来调整背景图片在盒中的位置
参数代表的x坐标和y坐标,可以用精确单位和方位名词来进行调整
length | 百分数 / 由浮点数字和单位表示符组成的长度值 |
position | top | center | botton | left | center | right 方位名词 |
1.如果指定的两个值都是方位名词,则和顺序无关
2.如果只指定了一个方位名词,另一个值则省略,第二个值默认center