CSS 背景速记
CSS background - Shorthand 属性
为了缩短代码,还可以将所有背景属性指定在一个属性中 单一属性。这称为background - Shorthand。
而不是写:
1 | body { background-color: #ffffff; |
您可以使用 background-shorthand 属性:
1 | 使用 shorthand 属性将背景属性设置为一个 声明: |
使用background - Shorthand属性时,属性值的顺序为:
background-colorbackground-imagebackground-repeatbackground-attachmentbackground-position
是否缺少某个属性值并不重要,只要 其他的按此顺序排列。请注意,在上面的示例中,我们没有使用 background-attachment 属性,因为它没有值。
所有 CSS 背景属性
| 属性 | 说明 |
|---|---|
| background | 设置背景属性 |
| background-attachment | 设置背景图像是固定的还是随页面的其余部分滚动 |
| background-clip | 指定背景的绘画区域 |
| background-color | 设置元素的背景色 |
| background-image | 设置元素的背景图像 |
| background-origin | 指定背景图像的位置 |
| background-position | 设置背景图像的起始位置 |
| background-repeat | 设置背景图像的重复方式 |
| background-size | 指定背景图像的大小 |
搜索
阅读量:
收藏数:
点赞数:


0评论