Style backgroundOrigin Property
Example
Position the background image relative to the content box:
document.getElementById("myDIV").style.backgroundOrigin = "content-box";
Try it Yourself »
Description
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.
See Also:
HTML Styles: The background Property
CSS Tutorial: CSS Backgrounds
CSS3 Tutorial: CSS3 Backgrounds
CSS Reference: The background-origin property
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 |
Browser Support
backgroundOrigin
is a CSS3 (1999) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.