aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/background-origin/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/css/background-origin/index.html')
-rw-r--r--files/zh-cn/web/css/background-origin/index.html169
1 files changed, 169 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/background-origin/index.html b/files/zh-cn/web/css/background-origin/index.html
new file mode 100644
index 0000000000..3109f95def
--- /dev/null
+++ b/files/zh-cn/web/css/background-origin/index.html
@@ -0,0 +1,169 @@
+---
+title: background-origin
+slug: Web/CSS/background-origin
+translation_of: Web/CSS/background-origin
+---
+<div>{{CSSRef}}</div>
+
+<h2 id="摘要">摘要</h2>
+
+<p> <code>background-origin</code> 规定了指定背景图片{{cssxref("background-image")}} 属性的原点位置的背景相对区域.</p>
+
+<p>注意:当使用 {{Cssxref("background-attachment")}} 为fixed时,该属性将被忽略不起作用。</p>
+
+<div class="note">假如<span style="line-height: 1.5;">{{cssxref("background")}}简写中没有设置该值,那么在 background 简写值后指定</span><span style="font-family: courier new,andale mono,monospace; line-height: 1.5;">background-origin,那么后面的值就会覆盖简写值,其实说白了,就是后出现的值会覆盖前面的值。</span></div>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="twopartsyntaxbox"><a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("background-origin")}}</pre>
+
+<pre>background-origin: border-box
+background-origin: padding-box
+background-origin: content-box
+
+background-origin: inherit
+</pre>
+
+<h3 id="属性值">属性值</h3>
+
+<dl>
+ <dt><code>border-box</code></dt>
+ <dd>背景图片的摆放以border区域为参考</dd>
+ <dt><code>padding-box</code></dt>
+ <dd>背景图片的摆放以padding区域为参考</dd>
+ <dt><code>content-box</code></dt>
+ <dd>背景图片的摆放以content区域为参考</dd>
+ <dt>
+ <h3 id="形式化语法" style="font-size: 1.71428571428571rem;">形式化语法</h3>
+ <a class="syntaxbox-help icon-only" href="https://developer.mozilla.org/docs/Web/CSS/Value_definition_syntax" lang="en">How to read CSS syntax.</a>
+
+ <pre class="syntaxbox" style="font-size: 14px; white-space: normal;">{{csssyntax("background-origin")}}</pre>
+ </dt>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: css"> .example {
+ border: 10px double;
+ padding: 10px;
+ background: url('image.jpg');
+ background-position: center left;
+ /* 背景将在内容区padding内部填充 */
+ background-origin: content-box;
+}
+</pre>
+
+<pre class="brush: css">#example2 {
+ border: 4px solid black;
+ padding: 10px;
+ background: url('image.gif');
+ background-repeat: no-repeat;
+ background-origin: border-box;
+ }</pre>
+
+<pre class="brush:css; highlight:[4];">div {
+ background-image: url('logo.jpg'), url('mainback.png');
+ background-position: top right, 0px 0px;
+ background-origin: content-box, padding-box;
+}</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSS3 Backgrounds', '#the-background-origin', 'background-origin')}}</td>
+ <td>{{Spec2('CSS3 Backgrounds')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>1.0 [3]</td>
+ <td>{{CompatGeckoDesktop("2.0")}} [1]</td>
+ <td>9.0 [2]</td>
+ <td>10.5</td>
+ <td>3.0 (522) [3]</td>
+ </tr>
+ <tr>
+ <td><code>content-box</code></td>
+ <td>1.0 [3]</td>
+ <td>{{CompatGeckoDesktop("2.0")}} [1]</td>
+ <td>9.0 [2]</td>
+ <td>{{CompatNo}}</td>
+ <td>3.0 (522) [3]</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>content-box</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] Gecko supported, from version 1.1 to version 1.9.2, which corresponds to Firefox 1.0 to 3.6 included, a different, and prefixed, syntax: <code>-moz-background-origin: padding | border</code>.</p>
+
+<p>[2] Internet Explorer up to version 7 behaves as if there was a <code>background-origin: border-box;</code> Internet Explorer 8 behaves as if it were <code>background-origin: padding-box;</code> which is the regular default value.</p>
+
+<p>[3] Webkit also supports the prefixed version of this proprietary, and in that case, in addition to the current keywords, the alternative synonyms: <code>padding</code>, <code>border</code>, and <code>content</code>.</p>
+
+<p>[4] Konqueror 3.5.4 supports<code> -khtml-background-origin</code>.</p>
+
+<h2 id="相关文献">相关文献</h2>
+
+<ul>
+ <li><a href="https://www.cnblogs.com/shytong/p/5077129.html">【CSS3】background-origin和background-clip的区别</a></li>
+</ul>