1. Computing

Discuss in my forum

background-origin

By , About.com Guide

Background image positioned by the content box

Background image positioned by the content box

Courtesy J Kyrnin

background-origin Description:

The background-origin property determines the position of a background relative to one of three parts of the box. You can use this property when layering multiple background images to change where the various images are placed in the box.

background-origin in CSS Versions:

background-origin Syntax:

background-origin: box;

Box has the values:

  • padding-box (default)
    A background positioned at 0,0 will start painting in the upper left of the padding box.
  • border-box
    A background positioned at 0,0 will start painting in the upper left of the border box.
  • content-box
    A background positioned at 0,0 will start painting in the upper left of the content box.

background-origin Initial Value:

padding-box

background-origin Applies To:

All elements.

background-origin Inheritance:

This property is not inherited.

background-origin Browser Support:

background-origin Examples:

See the background-origin examples.

Position relative to the border.

p {
  background-image: url("images/dog.jpg");
  background-origin: border-box;
}

Position relative to the content box:

p {
  background-image: url("images/dog.jpg");
  background-origin: content-box;
}

background-origin Special Notes:

  • If the background-attachment property is set to fixed, the background-origin will have no effect. Instead, the positioning area will be the initial container.
  • If background-clip is set to padding-box and background-origin is set to border-box, the position is the default value of top left, and the element has a non-zero border, then the top and left of the image will be clipped.

Other CSS Background References:

©2013 About.com. All rights reserved.