position:top center bottom lerft center right
![](https://img.haomeiwen.com/i12960326/3225666ff67271bd.png)
![](https://img.haomeiwen.com/i12960326/2a0450d5cd4f28da.png)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<div style="width:500px; height:300px; border:solid 2px red; background-color:red; background-image:url(1.png); background-repeat:no-repeat; background-position:10px 40px;"></div>
background缩写
衍生出来很多东西
background-color:red; 背景颜色
background-image:url(1.png); 背景图像(可以向img的src一样引进来一个路径)
background-repeat 背景重复方式
no-repeat 不重复
repeat 重复(横向纵向都重复) 默认值 、 我们不给background-repeat或者写了缩写了
repeat-x 横向重复
repeat-y 纵向重复
background-position:x y; 背景位置
必须是两个值
背景图像的位置
默认就是 left top
但我们写位置 必须是从 x开始 才是y
x:left center right
y:top center bottom
可以支持任意值
</body>
</html>
网友评论