CSS background-origin Property






<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]
-->




CSS background-origin Property



Previous
Complete CSS Reference
Next



Example


Let the background image start from the upper left corner of the content:



#example1 {
    border: 10px double black;
    padding:
25px;
    background: url(paper.gif);
   
background-repeat: no-repeat;
    background-origin:
content-box;
}

Try it Yourself »

More "Try it Yourself" examples below.




Definition and Usage


The background-origin property specifies the origin position (the background
positioning area) of a background image.


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
























Default value: padding-box
Inherited: no
Animatable: no. Read about animatable
Version: CSS3
JavaScript syntax: object.style.backgroundOrigin="content-box"
Try it




Browser Support


The numbers in the table specify the first browser version that fully supports the property.




















Property
background-origin 4.0 9.0 4.0 3.0 10.5




CSS Syntax



background-origin: padding-box|border-box|content-box|initial|inherit;


Property Values


































Value Description Play it
padding-box Default value. The background image starts from the upper left corner of the padding edge Play it »
border-box The background image starts from the upper left corner of the border Play it »
content-box The background image starts from the upper left corner of the content Play it »
initial Sets this property to its default value. Read about initial
Play it »
inherit Inherits this property from its parent element. Read about inherit




More Examples



Example


Set two background images for a <div> element. Let the "paper.gif"
background image starts from the upper left corner of the padding edge, and let
the "img_tree.gif" background image starts from the upper left corner of the
content:



#example1 {
    border: 10px double black;
   
padding: 25px;
    background: url(img_tree.gif), url(paper.gif);
   
background-repeat: no-repeat;
    background-origin:
content-box, padding-box;
}

Try it Yourself »



Related Pages


CSS tutorial: CSS Backgrounds


HTML DOM reference: backgroundOrigin property




Previous
Complete CSS Reference
Next

Popular posts from this blog

Chat program with C++ and SFML

Function to Return a JSON Like Objects Using VBA Collections and Arrays

Will my employers contract hold up in court?