aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/background-clip/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/css/background-clip/index.html')
-rw-r--r--files/zh-cn/web/css/background-clip/index.html127
1 files changed, 127 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/background-clip/index.html b/files/zh-cn/web/css/background-clip/index.html
new file mode 100644
index 0000000000..5f5f6cb3bb
--- /dev/null
+++ b/files/zh-cn/web/css/background-clip/index.html
@@ -0,0 +1,127 @@
+---
+title: background-clip
+slug: Web/CSS/background-clip
+tags:
+ - CSS
+ - CSS Background
+ - CSS Property
+ - Clip
+ - Reference
+translation_of: Web/CSS/background-clip
+---
+<div>{{CSSRef}}</div>
+
+<p><code>background-clip</code>  设置元素的背景(背景图片或颜色)是否延伸到边框、内边距盒子、内容盒子下面。</p>
+
+<div>{{EmbedInteractiveExample("pages/css/background-clip.html")}}</div>
+
+<p class="hidden">此交互样例的源代码被储存在GitHub库中.如果你想要对此交互样例工程有代码贡献,请点击 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a>并向我们发送拉取请求</p>
+
+<p>如果没有设置背景图片({{cssxref("background-image")}})或背景颜色({{cssxref("background-color")}}),那么这个属性只有在边框( {{cssxref("border")}})被设置为非固实(soild)、透明或半透明时才能看到视觉效果(与 {{cssxref("border-style")}} 或 {{cssxref("border-image")}} 有关),否则,本属性产生的样式变化会被边框覆盖。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush:css no-line-numbers notranslate">/* Keyword values */
+background-clip: border-box;
+background-clip: padding-box;
+background-clip: content-box;
+background-clip: text;
+
+/* Global values */
+background-clip: inherit;
+background-clip: initial;
+background-clip: unset;
+</pre>
+
+<h3 id="值">值</h3>
+
+<dl>
+ <dt><code>border-box</code></dt>
+ <dd>背景延伸至边框外沿(但是在边框下层)。</dd>
+ <dt><code>padding-box</code></dt>
+ <dd>背景延伸至内边距({{cssxref("padding")}})外沿。不会绘制到边框处。</dd>
+ <dt><code>content-box</code></dt>
+ <dd>背景被裁剪至内容区(content box)外沿。</dd>
+ <dt><code>text</code> {{experimental_inline}}</dt>
+ <dd>背景被裁剪成文字的前景色。</dd>
+</dl>
+
+<h3 id="标准语法">标准语法</h3>
+
+<pre class="syntaxbox notranslate">{{csssyntax}}</pre>
+
+<h2 id="示例">示例</h2>
+
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html notranslate">&lt;p class="border-box"&gt;The background extends behind the border.&lt;/p&gt;
+&lt;p class="padding-box"&gt;The background extends to the inside edge of the border.&lt;/p&gt;
+&lt;p class="content-box"&gt;The background extends only to the edge of the content box.&lt;/p&gt;
+&lt;p class="text"&gt;The background is clipped to the foreground text.&lt;/p&gt;
+</pre>
+
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css notranslate">p {
+ border: .8em darkviolet;
+ border-style: dotted double;
+ margin: 1em 0;
+ padding: 1.4em;
+ background: linear-gradient(60deg, red, yellow, red, yellow, red);
+ font: 900 1.2em sans-serif;
+ text-decoration: underline;
+}
+
+.border-box { background-clip: border-box; }
+.padding-box { background-clip: padding-box; }
+.content-box { background-clip: content-box; }
+
+.text {
+ background-clip: text;
+ -webkit-background-clip: text;
+ color: rgba(0,0,0,.2);
+}</pre>
+
+<h4 id="结果">结果</h4>
+
+<p>{{EmbedLiveSample('Examples', 600, 580)}}</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSS3 Backgrounds', '#the-background-clip', 'background-clip')}}</td>
+ <td>{{Spec2('CSS3 Backgrounds')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS4 Backgrounds', '#background-clip', 'background-clip')}}</td>
+ <td>{{Spec2('CSS4 Backgrounds')}}</td>
+ <td>Add <code>text</code> value.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">此页面中的兼容性表是根据结构化数据生成的. 如果你想要对此数据有所贡献, 请点击 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并且向我们发送拉取请求.</p>
+
+<p>{{Compat("css.properties.background-clip")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>The {{cssxref("clip-path")}} property creates a clipping region that defines what part of an <em>entire element</em> should be displayed.</li>
+ <li>Background properties: {{cssxref("background")}}, {{cssxref("background-color")}}, {{cssxref("background-image")}}</li>
+ <li><a href="/en-US/docs/Web/CSS/box_model">Introduction to the CSS box model</a></li>
+</ul>