First, Background-position properties
With this property, you can also specify the position of the pattern from the edge of the container without determining the size of the container, but you need to specify a fallback scheme for browsers that do not support the property, otherwise the pattern will be placed by default in the upper-left corner.
1 <HTML>2 <Head>3 <MetaCharSet= "Utf-8">4 <title>Flexible background positioning</title>5 <styletype= "Text/css">6 Div{7 background:URL (http://csssecrets.io/images/code-pirate.svg)8 No-repeat bottom Right #58a;/*bottom right is the specified fallback scheme, avoid placing it in the upper left corner*/9 Ten background-position:Right 20px Bottom 10px; One A Max-width:10em; - Min-height:5em; - padding:10px; the Color: White; - Font:100%/1 Sans-serif; - } - </style> + </Head> - <Body> + <Div></Div> A </Body> at </HTML>
Second, Content-box
Each element has 3 rectangular borders, Border-box,padding-box,content-box, and by default, the background picture is placed from Padding-box.
If you add an attribute value:
Background-position:content-box, the background image will be placed from the content box position, in this way, you can also achieve the effect of the inner margin.
Third, calc () function
The offset of 20px from the right and below is actually the offset from above and below (100%-20px); You can use the Calc function to note that you need to add a space before +/-.
Background-position:calc (100%-20px), Calc (100%-20px);
[CSS] "CSS Secrets" Learning (iii)-Flexible background positioning