CSS 背景图片 添加 重复和定位。

1.背景色

1.属性:background-color
2.注意:背景颜的会填充到元素的边框 内边距 内容区域。

2.背景图片

属性:background-image
取值:URL(图像路径)

小星星

3.背景重复

1.默认情况 背景图会在水平 和 垂直两个方向(就是平铺)
属性:background-repeat 取值repeat:默认值,水平垂直平铺。 repeat-x: 水平平铺; repeat-y: 垂直平铺; no-repeart:不平铺;

4.背景图像固定

属性:background-attachment
取值 fixed,背景图像固定
background-attachment:fixed;

5.背景定位

改变背景图像在元素中的位置
属性:background-position
取值:x y
x表示水平方向移动 +向右 -向左
y表示垂直方向 +向上 -向下
x% y% : 0% 0% : 显示在元素的左上方 100% 100% : 显示在元素的右下方 50% 50% : 居中 left :靠左 right:靠右 center :将元素显示在水平或垂直方向的中间 top:靠上 bottom:靠下 background-position:left top; background-position:top left; background-position:center;

2019-02-21

评论

暂无评论