aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/mask-repeat
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/mask-repeat
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/mask-repeat')
-rw-r--r--files/zh-cn/web/css/mask-repeat/index.html186
1 files changed, 186 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/mask-repeat/index.html b/files/zh-cn/web/css/mask-repeat/index.html
new file mode 100644
index 0000000000..f052ccc58d
--- /dev/null
+++ b/files/zh-cn/web/css/mask-repeat/index.html
@@ -0,0 +1,186 @@
+---
+title: mask-repeat
+slug: Web/CSS/mask-repeat
+translation_of: Web/CSS/mask-repeat
+---
+<div>{{CSSRef}}{{SeeCompatTable}}</div>
+
+<p><a href="/zh-CN/docs/Web/CSS">CSS</a> 的 <strong><code>mask-repeat</code></strong> 属性定义了遮罩图片是否重复显示多个副本,以及如何重复。一个遮罩图片可以水平重复、垂直重复或双向重复,也可以不重复。</p>
+
+<pre class="brush: css no-line-numbers">/* One-value syntax */
+mask-repeat: repeat-x;
+mask-repeat: repeat-y;
+mask-repeat: repeat;
+mask-repeat: space;
+mask-repeat: round;
+mask-repeat: no-repeat;
+
+/* Two-value syntax: horizontal | vertical */
+mask-repeat: repeat space;
+mask-repeat: repeat repeat;
+mask-repeat: round space;
+mask-repeat: no-repeat round;
+
+/* Multiple values */
+mask-repeat: space round, no-repeat;
+mask-repeat: round repeat, space, repeat-x;
+
+/* Global values */
+mask-repeat: inherit;
+mask-repeat: initial;
+mask-repeat: unset;
+</pre>
+
+<p>默认情况下,重复的图片会被剪切为图片的大小,但他们可以自行缩放适应(使用 <code>round</code>),或者从一端到另一端均匀分布(使用 <code>space</code>)。</p>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="语法">语法</h2>
+
+<p>One or more <code>&lt;repeat-style&gt;</code> values, separated by commas.</p>
+
+<h3 id="取值">取值</h3>
+
+<dl>
+ <dt><code>&lt;repeat-style&gt;</code></dt>
+ <dd>单值语法可将两个值简写为一个:</dd>
+ <dd>
+ <table class="standard-table">
+ <tbody>
+ <tr>
+ <td><strong>单值</strong></td>
+ <td><strong>与之等效的双值</strong></td>
+ </tr>
+ <tr>
+ <td><code>repeat-x</code></td>
+ <td><code>repeat no-repeat</code></td>
+ </tr>
+ <tr>
+ <td><code>repeat-y</code></td>
+ <td><code>no-repeat repeat</code></td>
+ </tr>
+ <tr>
+ <td><code>repeat</code></td>
+ <td><code>repeat repeat</code></td>
+ </tr>
+ <tr>
+ <td><code>space</code></td>
+ <td><code>space space</code></td>
+ </tr>
+ <tr>
+ <td><code>round</code></td>
+ <td><code>round round</code></td>
+ </tr>
+ <tr>
+ <td><code>no-repeat</code></td>
+ <td><code>no-repeat no-repeat</code></td>
+ </tr>
+ </tbody>
+ </table>
+ 在双值语法中,第一个值代表了水平方向的行为,第二个值代表了垂直方向的行为。下面是每个选项的用法解释:</dd>
+ <dd>
+ <table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>repeat</code></td>
+ <td>The image is repeated as much as needed to cover the whole mask painting area. The last image will be clipped if it doesn't fit.</td>
+ </tr>
+ <tr>
+ <td><code>space</code></td>
+ <td>The image is repeated as much as possible without clipping. The first and last images are pinned to either side of the element, and whitespace is distributed evenly between the images. The {{cssxref("mask-position")}} property is ignored unless only one image can be displayed without clipping. The only case where clipping happens using <code>space</code> is when there isn't enough room to display one image.</td>
+ </tr>
+ <tr>
+ <td><code>round</code></td>
+ <td>As the allowed space increases in size, the repeated images will stretch (leaving no gaps) until there is room for another one to be added. When the next image is added, all of the current ones compress to allow room. Example: An image with an original width of 260px, repeated three times, might stretch until each repetition is 300px wide, and then another image will be added. They will then compress to 225px.</td>
+ </tr>
+ <tr>
+ <td><code>no-repeat</code></td>
+ <td>The image is not repeated (and hence the mask painting area will not necessarily be entirely covered). The position of the non-repeated mask image is defined by the {{cssxref("mask-position")}} CSS property.</td>
+ </tr>
+ </tbody>
+ </table>
+ </dd>
+</dl>
+
+<h3 id="正式语法">正式语法</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="例子">例子</h2>
+
+<h3 id="单值">单值</h3>
+
+<h4 id="CSS">CSS</h4>
+
+<pre class="brush: css; highlight[6]">#masked {
+ width: 250px;
+ height: 250px;
+ background: blue linear-gradient(red, blue);
+ mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg);
+ mask-repeat: repeat; /* 可在实时示例 live sample 中修改 */
+ margin-bottom: 10px;
+}
+</pre>
+
+<div class="hidden">
+<h4 id="HTML">HTML</h4>
+
+<pre class="brush: html">&lt;div id="masked"&gt;
+&lt;/div&gt;
+&lt;select id="repetition"&gt;
+ &lt;option value="repeat-x"&gt;repeat-x&lt;/option&gt;
+ &lt;option value="repeat-y"&gt;repeat-y&lt;/option&gt;
+ &lt;option value="repeat" selected&gt;repeat&lt;/option&gt;
+ &lt;option value="space"&gt;space&lt;/option&gt;
+ &lt;option value="round"&gt;round&lt;/option&gt;
+ &lt;option value="no-repeat"&gt;no-repeat&lt;/option&gt;
+&lt;/select&gt;
+</pre>
+
+<h4 id="JavaScript_Content">JavaScript Content</h4>
+
+<pre class="brush: js">var repetition = document.getElementById("repetition");
+repetition.addEventListener("change", function (evt) {
+ document.getElementById("masked").style.maskRepeat = evt.target.value;
+});
+</pre>
+</div>
+
+<p>{{EmbedLiveSample("Single_value", "290px", "290px")}}</p>
+
+<h3 id="使用多个遮罩图片">使用多个遮罩图片</h3>
+
+<p>You can specify a different <code>&lt;repeat-style&gt;</code> for each mask image, separated by commas:</p>
+
+<pre class="brush: css">.examplethree {
+ mask-image: url('mask1.png'), url('mask2.png');
+ mask-repeat: repeat-x, repeat-y;
+}
+</pre>
+
+<p>Each image is matched with the corresponding repeat style, from first specified to last.</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("CSS Masks", "#the-mask-repeat", "mask-repeat")}}</td>
+ <td>{{Spec2("CSS Masks")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("css.properties.mask-repeat")}}</p>