CSS3 background-origin property
Example
Background image positioned relative to the content box:
div
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-position:left;
background-origin:content-box;
}
Try it »
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| background-origin | 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
Tag Definition and Usage Notes
The background-origin property specifies where the background-position property should be relative to.
NoteIf the background image's background-attachment is "fixed", this property has no effect.
| Default value: | padding-box |
|---|---|
| Inherited: | no |
| Version: | CSS3 |
| JavaScript syntax: | object object.style.backgroundOrigin="content-box" |
Syntax
background-origin: padding-box|border-box|content-box;
| Value | Description |
|---|---|
| padding-box | Background image relative to the padding box |
| border-box | Background image relative to the border box |
| content-box | Background image relative to the content box |
Related Articles
CSS3 tutorial: CSS3 Backgrounds