--- title: mask-border slug: Web/CSS/mask-border translation_of: Web/CSS/mask-border ---
CSS 属性 mask-border
允许你创建一个紧贴元素边框边缘的mask.
该属性为以下属性的简写: {{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")}}. 与其他简写的属性一样,任何一个漏写的子属性,将会被设置为他们的初始值.
/* 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;
<'mask-border-source'>
<'mask-border-slice'>
<'mask-border-width'>
<'mask-border-outset'>
<'mask-border-repeat'>
<'mask-border-mode'>
{{csssyntax}}
在此范例中,我们将使用钻石图案来给元素添加mask. mask的源文件是一个 ".png" 文件,大小为 90像素 * 90 像素,三颗钻石垂直和水平交叉;
<div id="bitmap">This element is surrounded by a bitmap-based mask border! Pretty neat, isn't it?</div>
为了适应一个钻石的大小,我们使用90/3 或者30,用于设置将图像切割至边角以及边缘区域的值,并设置repeat属性为 round
,该属性使得切片均匀贴合,例如:没有裁剪和空隙.
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 */ }
{{EmbedLiveSample("Example")}}
Specification | Status | Comment |
---|---|---|
{{SpecName("CSS Masks", "#propdef-mask-border", "mask-border")}} | {{Spec2("CSS Masks")}} | Initial definition |
{{cssinfo}}
TBD