English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS properties大全

CSS3 background-Usage and examples of the origin attribute

CSS background-The origin attribute specifies the positioning area of the background, that is, usingbackground-imageThe position of the image origin specified by the attribute.

The following table summarizes the usage context and version history of this attribute.

Default value:padding-box
Applicable to:All elements. It also applies to::first-letterand::first-line.
Inheritance:None
Animated production:否。No. Please see.
Animation properties CSS3version:
new feature    JavaScript syntax:    object-object.style.backgroundOrigin="content

background-box"

The syntax of origin

background-The syntax of this attribute is as follows:-origin: border-box | padding-box | content

box | initial | inherit-The following example demonstrates how to use background

Example
    .box { 25height:
    width: 15height:
    0px; 10padding:
    px; 6border:333px dashed #
    ;/background: url("images-sky.jpg") no
    background-repeat;
    background-size: contain;-origin: content
box;
}/Test and see‹

Note:-origin if the value attribute is ignoredbackground-attachmentThe attribute is specified as fixed.

Attribute value

The following table describes the values of this attribute.

ValueDescription
border-boxSpecify that the background extends to the outer edge of the border. The background is drawn below the border.
padding-boxSpecify that the background extends to the outer edge of the padding. The background is not drawn below the border. This is the default value.
content-boxSpecify that the background is drawn only within the content box (clipped to). The background is not drawn below the border and padding area.
initialSet this attribute to its default value.
inheritIf specified, the associated element adopts its parent element's background-The calculated value of the origin attribute.

Browser compatibility

background-Browser compatibility, the origin attribute is supported by all mainstream browsers.

  • Firefox 4+

  • Google Chrome4+

  • Internet Explorer 9+

  • Apple Safari 3+

  • Opera 10.5+

Further reading

Please refer to the following tutorials:CSS3Background,CSS3Background.

Related attributes:background,background-attachment,background-color,background-image,background-clip,background-position,background-repeat,background-size.