Style backgroundOrigin Property
Example
Position the background image relative to the content box:
document.getElementById("myDIV").style.backgroundOrigin = "content-box";
Try it Yourself »
Definition and Usage
The backgroundOrigin property sets or returns what the background-position property is relative to.
Note: If the background-attachment property for the background image is "fixed", this property has no effect.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
backgroundOrigin | 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
Syntax
Return the backgroundOrigin property:
object.style.backgroundOrigin
Set the backgroundOrigin property:
object.style.backgroundOrigin = "padding-box|border-box|content-box|initial|inherit"
Property Values
Value | Description |
---|---|
padding-box | Default value. The background image is positioned relative to the padding box |
border-box | The background image is positioned relative to the border box |
content-box | The background image is positioned relative to the content box |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | padding-box |
---|---|
Return Value: | A String, representing the background-origin property of an element |
CSS Version | CSS3 |
Related Pages
CSS reference: background-origin property