HTML DOM Style backgroundOrigin property
Examples
With respect to the contents of the box locate the background image:
document.getElementById("myDIV").style.backgroundOrigin="content-box";
try it"
Definition and Usage
backgroundOrigin property sets or returns the background-position property is positioned relative to what.
Note: If thebackground-attachment properties of the background image is "fixed", the property does not work.
Browser Support
IE9 +, Firefox, Opera, Chrome and Safari support background-origin property.
grammar
Back backgroundOrigin properties:
object .style.backgroundOrigin
Setting backgroundOrigin properties:
object .style.backgroundOrigin="padding-box|border-box|content-box|initial|inherit"
Property Value
值 | 描述 |
---|---|
padding-box | 默认值。背景图像相对于填充框进行定位。 |
border-box | 背景图像相对于边界框进行定位。 |
content-box | 背景图像相对于内容框进行定位。 |
initial | 设置该属性为它的默认值。请参阅 initial 。 |
inherit | 从父元素继承该属性。请参阅 inherit 。 |
technical details
Defaults: | padding-box |
---|---|
return value: | String representing the background-origin attribute of the element. |
CSS version | CSS3 |
related articles
CSS Reference Manual: background attribute-Origin