CSS 3 background-origin属性
CSS background-origin 属性指定 background-position 属性应该是相对位置
如果背景图像 background-attachment 是 "固定",这个属性没有任何效果
| 默认值 | padding-box |
|---|---|
| 继承 | no |
| 版本 | CSS3 |
| JavaScript 语法 | object.style.backgroundOrigin="content-box" |
语法
background-origin: padding-box|border-box|content-box;
值说明
| 值 | 描述 |
|---|---|
| padding-box | 背景图像填充框的相对位置 |
| border-box | 背景图像边界框的相对位置 |
| content-box | 背景图像的相对位置的内容框 |
浏览器支持
下表中的数字表示支持该属性的第一个浏览器版本号
| 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
范例
内容框相对定位的背景图片
div { background-image:url('smiley.gif'); background-repeat:no-repeat; background-position:left; background-origin:content-box; }
相关文章
CSS3 基础教程: CSS3 Backgrounds