YouTip LogoYouTip

Prop Style Backgroundorigin

HTML DOM Style backgroundOrigin Property

HTML DOM Style backgroundOrigin Property

HTML DOM Style backgroundOrigin Property

-- Learning is not just about technology, but also about dreams!

JavaScript Reference Manual

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<source>

HTML DOM Table Object

Style backgroundOrigin Property

Style Object Reference Manual Style Object

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 where the background-position property is relative to.

Note: This property has no effect if the background-attachment property of the background image is "fixed".


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The background-origin property is supported in IE9+, Firefox, Opera, Chrome, and Safari.


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. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: padding-box
Return value: A string, representing the background-origin property of an element.
CSS Version: CSS3

Related Articles

CSS Reference: background-origin property


Style Object Reference Manual Style Object

← Prop Style BackgroundsizeProp Style Backgroundclip β†’