css background-origin property


  Translation results:

background

UK[ˈbækgraʊnd] US[ˈbækˌɡraʊnd]

n. (painting, etc.) background; background color; background information; soundtrack

Plural: backgrounds

origin

英[ˈɒrɪdʒɪn]  美[ˈɔ:rɪdʒɪn]  

n. Origin; origin, root; [number ]Origin, starting point; [solution] (tendon, nerve) starting point

Plural: origins

css background-origin propertysyntax

How to use the background-origin attribute?

The background-origin attribute is used to set the positioning area of ​​the background image. Syntax: background-origin: padding-box|border-box|content-box; The three attribute values ​​represent respectively: positioning relative to the padding box, positioning relative to the border box, and positioning relative to the content box.

Function: Specifies the position relative to which the background-position attribute is positioned.

Syntax: background-origin: padding-box|border-box|content-box;

Description: padding-box The background image is positioned relative to the padding box. border-box The background image is positioned relative to the border box. content-box The background image is positioned relative to the content box.​

Note: If the background-attachment attribute of the background image is "fixed", this attribute has no effect.

css background-origin propertyexample

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
border:1px solid black;
padding:35px;
background-image:url('http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg');
background-repeat:no-repeat;
background-position:left;
}
#div1
{
background-origin:border-box;
}
#div2
{
background-origin:content-box;
}
</style>
</head>
<body>

<p>background-origin:border-box:</p>
<div id="div1">
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
</div>

<p>background-origin:content-box:</p>
<div id="div2">
这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。这是文本。
</div>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A