background-Origin属性指定background-position属性应该是相对位置。
注意如果背景图像background-attachment是"固定",这个属性没有任何效果。
| 默认值: | padding-box |
|---|---|
| 继承: | no |
| 版本: | CSS3 |
| JavaScript 语法: | object object.style.backgroundOrigin="content-box" |
background-origin: padding-box|border-box|content-box;
| 值 | 描述 |
|---|---|
| padding-box | 背景图像填充框的相对位置 |
| border-box | 背景图像边界框的相对位置 |
| content-box | 背景图像的相对位置的内容框 |
内容框相对定位的背景图片:
div {
background - image: url('smiley.gif');
background - repeat: no - repeat;
background - position: left;
background - origin: content - box;
}
尝试一下 »表格中的数字表示支持该属性的第一个浏览器版本号。
| 属性 | |||||
|---|---|---|---|---|---|
| background-origin | 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
CSS3 教程: CSS3 Backgrounds
在线实例
字符集 & 工具
最新更新
站点信息