Revision 28798 of background-origin

  • Revision slug: CSS/background-origin
  • Revision title: background-origin
  • Revision id: 28798
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 34 words added, 197 words removed

Revision Content

{{ CSSRef() }}

Summary

The background-origin CSS property determines the background positioning area (the origin of a background-image).
background-origin does not apply when {{ Cssxref("background-attachment") }} is fixed.

This property is reset to its initial value by the {{ Cssxref("background") }} shorthand property.

  • {{ Xref_cssinitial() }}: {{ Cssxref("padding") }}
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

Syntax

background-origin: [padding-box | border-box | content-box][, [border-box | padding-box | content-box]]*

Values

border-box
The background extends to the outside edge of the border (but underneath the border in z-ordering).
padding-box
No background is drawn below the border (background extends to the outside edge of the padding).
content-box
The background is painted within (clipped to) the content box.

Examples

 .example {
   border: 10px double;
   padding: 10px;
   background: url('image.jpg');
   background-position: center left;
   /* The background will be inside the padding */       
   background-origin: content-box;
}
div {
  background-image: url('mainback.png'), url('logo.jpg');
  background-position: 0px 0px, top right;
  background-origin: padding-box, content-box;
}

Browser compatibility

Browser Lowest version Support of
Chrome 1.0 -webkit-background-origin: padding | border | content
-webkit-background-origin: padding-box | border-box | content-box
1.0 background-origin: padding | border | content
background-origin: padding-box | border-box | content-box
Firefox (Gecko) 1.0-3.6 (1.2-1.9.2) -moz-background-origin: padding | border | content
4.0 (2.0) background-origin: padding-box | border-box | content-box
Internet Explorer 9.0 [*] background-origin: padding-box | border-box | content-box
Opera 10.5 background-origin: padding-box | border-box | content-box
Safari (WebKit) 3.0 (522) -webkit-background-origin: padding | border | content
4.0 -webkit-background-origin: padding-box | border-box | content-box
5.0 background-origin: padding-box | border-box | content-box
  • [*] IE up to version 7 behaves as if it were background-origin: border-box;
  • [**] IE 8 behaves as if it were background-origin: padding-box;
  • Konqueror 3.5.4 supports -khtml-background-origin.

Specifications

See also

  • {{ cssxref("-moz-background-size") }}
  • {{ CSS_Reference:Background() }}

{{ languages( { "de":"de/CSS/background-origin", "fr": "fr/CSS/-moz-background-origin", "ja": "ja/CSS/-moz-background-origin", "pl": "pl/CSS/-moz-background-origin" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<p>The<code> background-origin </code>CSS property determines the background positioning area (the origin of a background-image).<br> <code>background-origin </code>does not apply when {{ Cssxref("background-attachment") }} is<code> <code>fixed</code></code>.</p>
<p>This property is reset to its initial value by the {{ Cssxref("background") }} shorthand property.</p>
<ul> <li>{{ Xref_cssinitial() }}: {{ Cssxref("padding") }}</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: as specified<br> <code> </code></li>
</ul>
<h3>Syntax</h3>
<pre>background-origin: [<code>padding-box | border-box | conten</code><code>t-box</code>][, [<code>border-box | padding-box | conten</code><code>t-box</code>]]*
</pre>
<h3>Values</h3>
<dl> <dt>border-box</dt> <dd>The background extends to the outside edge of the border (but underneath the border in z-ordering).</dd> <dt>padding-box</dt> <dd>No background is drawn below the border (background extends to the outside edge of the padding).</dd> <dt>content-box</dt> <dd>The background is painted within (clipped to) the content box.</dd>
</dl>
<h3>Examples</h3>
<pre> .example {
   border: 10px double;
   padding: 10px;
   background: url('image.jpg');
   background-position: center left;
   /* The background will be inside the padding */       
   background-origin: content-box;
}
</pre>
<pre>div {
  background-image: url('mainback.png'), url('logo.jpg');
  background-position: 0px 0px, top right;
  background-origin: padding-box, content-box;
}
</pre>
<h3>Browser compatibility</h3>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>Lowest version</th> <th>Support of</th> </tr> <tr> <td rowspan="2">Chrome</td> <td>1.0</td> <td><code>-webkit-background-origin: padding | border | content </code><br> <code>-webkit-background-origin: padding-box | border-box | content-box</code></td> </tr> <tr> <td>1.0</td> <td><code>background-origin: padding | border | content </code><br> <code>background-origin: padding-box | border-box | content-box</code></td> </tr> <tr> <td rowspan="2">Firefox (Gecko)</td> <td>1.0-3.6 (1.2-1.9.2)</td> <td><code>-moz-background-origin: padding | border | content</code></td> </tr> <tr> <td>4.0 (2.0)</td> <td><code>background-origin: padding-box | border-box | content-box</code></td> </tr> <tr> <td>Internet Explorer</td> <td>9.0 [*]</td> <td><code>background-origin: padding-box | border-box | content-box</code></td> </tr> <tr> <td>Opera</td> <td>10.5</td> <td><code>background-origin: padding-box | border-box | content-box</code></td> </tr> <tr> <td rowspan="3">Safari (WebKit)</td> <td>3.0 (522)</td> <td><code>-webkit-background-origin: padding | border | content </code></td> </tr> <tr> <td>4.0</td> <td><code>-webkit-background-origin: padding-box | border-box | content-box</code></td> </tr> <tr> <td>5.0</td> <td><code>background-origin: padding-box | border-box | content-box</code></td> </tr> </tbody>
</table>
<ul> <li>[*] IE up to version 7 behaves as if it were <code>background-origin: border-box;</code></li> <li>[**] IE 8 behaves as if it were <code>background-origin: padding-box;</code><br> <code> </code></li> <li>Konqueror 3.5.4 supports <code>-khtml-background-origin</code>.</li>
</ul>
<h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/css3-background/#background-origin" title="http://www.w3.org/TR/css3-background/#background-origin">CSS 3 Background and borders #background-origin</a><br> Specifies the values<code> border-box | padding-box | content-box.</code></li>
</ul>
<h3>See also</h3>
<ul> <li>{{ cssxref("-moz-background-size") }}</li> <li>{{ CSS_Reference:Background() }}</li>
</ul>
<p>{{ languages( { "de":"de/CSS/background-origin", "fr": "fr/CSS/-moz-background-origin", "ja": "ja/CSS/-moz-background-origin", "pl": "pl/CSS/-moz-background-origin" } ) }}</p>
Revert to this revision