diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/mask-border | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/mask-border')
-rw-r--r-- | files/zh-cn/web/css/mask-border/index.html | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/mask-border/index.html b/files/zh-cn/web/css/mask-border/index.html new file mode 100644 index 0000000000..ecd3d44814 --- /dev/null +++ b/files/zh-cn/web/css/mask-border/index.html @@ -0,0 +1,105 @@ +--- +title: mask-border +slug: Web/CSS/mask-border +translation_of: Web/CSS/mask-border +--- +<div>{{cssref}}{{SeeCompatTable}}</div> + +<p><a href="/en-US/docs/Web/CSS">CSS</a> 属性 <strong><code>mask-border</code></strong> 允许你创建一个紧贴元素边框边缘的mask.</p> + +<p>该属性为以下属性的<a href="/en-US/docs/Web/CSS/Shorthand_properties">简写</a>: {{cssxref("mask-border-source")}}, {{cssxref("mask-border-slice")}}, {{cssxref("mask-border-width")}}, {{cssxref("mask-border-outset")}}, {{cssxref("mask-border-repeat")}}, and {{cssxref("mask-border-mode")}}. 与其他简写的属性一样,任何一个漏写的子属性,将会被设置为他们的<a href="/en-US/docs/Web/CSS/initial_value">初始值</a>.</p> + +<h2 id="语法">语法</h2> + +<pre class="brush: css no-line-numbers">/* source | slice */ +mask-border: url('border-mask.png') 25; + +/* source | slice | repeat */ +mask-border: url('border-mask.png') 25 space; + +/* source | slice | width */ +mask-border: url('border-mask.png') 25 / 35px; + +/* source | slice | width | outset | repeat | mode */ +mask-border: url('border-mask.png') 25 / 35px / 12px space alpha; +</pre> + +<h3 id="Values">Values</h3> + +<dl> + <dt><code><'mask-border-source'></code></dt> + <dd>该属性为源图像. 参见 {{cssxref("mask-border-source")}}.</dd> + <dt><code><'mask-border-slice'></code></dt> + <dd>将源图像切割后的区域的尺寸,最多可指定四个值. 参见 {{cssxref("mask-border-slice")}}.</dd> + <dt><code><'mask-border-width'></code></dt> + <dd>边框mask的宽度. 最多可指定四个值. 参见 {{cssxref("mask-border-width")}}.</dd> + <dt><code><'mask-border-outset'></code></dt> + <dd>边框mask距离元素外边界的距离. 最多可指定四个值. 参见 {{cssxref("mask-border-outset")}}.</dd> + <dt><code><'mask-border-repeat'></code></dt> + <dd>定义如何调整源图像的边缘区域以适应边框mask的尺寸. 最多可指定四个值. 参见 {{cssxref("mask-border-repeat")}}.</dd> + <dt><code><'mask-border-mode'></code></dt> + <dd>定义是否将源图片设置为明亮度mask,或者透明度mask. 参见 {{cssxref("mask-border-mode")}}.</dd> +</dl> + +<h3 id="形式语法">形式语法</h3> + +<pre class="syntaxbox">{{csssyntax}}</pre> + +<h2 id="范例">范例</h2> + +<h3 id="Bitmap">Bitmap</h3> + +<p>在此范例中,我们将使用钻石图案来给元素添加mask. mask的源文件是一个 ".png" 文件,大小为 90像素 * 90 像素,三颗钻石垂直和水平交叉;</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/15836/mask-border-diamonds.png" style="height: 90px; width: 90px;"></p> + +<h4 id="HTML">HTML</h4> + +<pre class="brush: html"><div id="bitmap">This element is surrounded by a bitmap-based mask border! Pretty neat, isn't it?</div></pre> + +<h4 id="CSS">CSS</h4> + +<p>为了适应一个钻石的大小,我们使用90/3 或者30,用于设置将图像切割至边角以及边缘区域的值,并设置repeat属性为 <code>round</code> ,该属性使得切片均匀贴合,例如:没有裁剪和空隙.</p> + +<pre class="brush: css">div { + width: 200px; + background-color: lavender; + border: 18px solid salmon; + padding: 10px; + + mask-border: + url("https://mdn.mozillademos.org/files/15836/mask-border-diamonds.png") /* source */ + 30 / /* slice */ + 36px 18px /* width */ + round; /* repeat */ +} +</pre> + +<h4 id="Result">Result</h4> + +<p>{{EmbedLiveSample("Example")}}</p> + +<h2 id="Specifications">Specifications</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("CSS Masks", "#propdef-mask-border", "mask-border")}}</td> + <td>{{Spec2("CSS Masks")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<p>{{cssinfo}}</p> + +<h2 id="浏览器兼容性Edit">浏览器兼容性<a class="button section-edit only-icon" href="https://developer.mozilla.org/en-US/docs/Web/CSS/border-image$edit#Browser_compatibility" rel="nofollow, noindex"><span>Edit</span></a></h2> + +<p><span>TBD</span></p> |