--- title: mask-image slug: Web/CSS/mask-image translation_of: Web/CSS/mask-image --- <div>{{CSSRef}}{{SeeCompatTable}}</div> <h2 id="概要">概要</h2> <p><strong><code>mask-image</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a>属性用于设置元素上遮罩层的图像。</p> <p>{{cssinfo}}</p> <h2 id="语法">语法</h2> <pre class="brush:css">/* Keyword value */ mask-image: none; /* <mask-source> value */ mask-image: url(masks.svg#mask1); /* <image< values */ mask-image: linear-gradient(rgba(0, 0, 0, 1.0), transparent); mask-image: image(url(mask.png), skyblue); /* Multiple values */ mask-image: image(url(mask.png), skyblue), linear-gradient(rgba(0, 0, 0, 1.0), transparent); /* Global values */ mask-image: inherit; mask-image: initial; mask-image: unset; </pre> <h3 id="Values">Values</h3> <dl> <dt><code>none</code></dt> <dd>默认值,透明的黑色图像层,也就是没有遮罩层。</dd> <dt><code><mask-source></code></dt> <dd><code><mask></code>或CSS图像的url</dd> <dd>{{cssxref("<image>")}}</dd> <dd>图片作为遮罩层</dd> </dl> <h3 id="Formal_syntax">Formal syntax</h3> {{csssyntax}} <h2 id="例子">例子</h2> <h3 id="CSS">CSS</h3> <pre class="brush: css; highlight[5]">#masked { width: 100px; height: 100px; background-color: #8cffa0; mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); -webkit-mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); } </pre> <h3 id="HTML">HTML</h3> <pre class="brush: html"><div id="masked"></div> </pre> <p>{{EmbedLiveSample('例子', '100px', '100px')}}</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", "#the-mask-image", "mask-image")}}</td> <td>{{Spec2("CSS Masks")}}</td> <td>Initial definition</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> {{Compat("css.properties.mask-image")}}