属性 | 描述 | 版本 |
---|---|---|
background-color | 背景颜色。 | CSS1 |
background-image | 背景图像。 | CSS1 |
background-position | 背景图像位置。 | CSS1 |
background-size | 背景图像的尺寸大小。 | CSS3 |
background-repeat | 背景图像如何铺排填充。 | CSS1 |
background-origin | 背景图像位置的参考原点。 | CSS3 |
background-clip | 背景图像向外裁剪的区域。 | CSS3 |
background-attachment | 背景图像是随对象内容滚动还是固定的。 | CSS1 |
background | 复合属性。设置对象的背景特性。 | CSS1 |
background-color
background-color 属性设置一个元素的背景颜色。
例:红色背景
background:red;
例:线性渐变:
background:linear-gradient(90deg,red 10px,pink 20%,green);
background:linear-gradient(to left,red 10px,pink 20%,green);
例:径向渐变:
background:linear-gradient(to left,red 10px,pink 20%,green);
background:radial-gradient(circle at center,red 10px,pink 20%,green);
例:重复渐变
background:repeating-radial-gradient(circle at center,red 10px,pink 20%);
background
background 是背景缩写属性,可以在一个声明中设置所有的背景属性。
完整的写法:background:bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment;
background: #eee url(bg.png) center/cover no-repeat border-box content-box fixed;
来源:CSDN
作者:shenwen5225
链接:https://blog.csdn.net/shenwen522519753/article/details/103679230