mask-border-slice - CSS: Cascading Style Sheets 编辑

The mask-border-slice CSS property divides the image set by mask-border-source into regions. These regions are used to form the components of an element's mask border.

Syntax

/* All sides */
mask-border-slice: 30%;

/* vertical | horizontal */
mask-border-slice: 10% 30%;

/* top | horizontal | bottom */
mask-border-slice: 30 30% 45;

/* top | right | bottom | left */
mask-border-slice: 7 12 14 5;

/* Using the `fill` keyword */
mask-border-slice: 10% fill 7 12;

/* Global values */
mask-border-slice: inherit;
mask-border-slice: initial;
mask-border-slice: unset;

The mask-border-slice property may be specified using one to four <number-percentage> values to represent the position of each image slice. Negative values are invalid; values greater than their corresponding dimension are clamped to 100%.

  • When one position is specified, it creates all four slices at the same distance from their respective sides.
  • When two positions are specified, the first value creates slices measured from the top and bottom, the second creates slices measured from the left and right.
  • When three positions are specified, the first value creates a slice measured from the top, the second creates slices measured from the left and right, the third creates a slice measured from the bottom.
  • When four positions are specified, they create slices measured from the top, right, bottom, and left in that order (clockwise).

The optional fill value, if used, can be placed anywhere in the declaration.

Values

<number>
Represents an edge offset in pixels for raster images and coordinates for vector images. For vector images, the number is relative to the element's size, not the size of the source image, so percentages are generally preferable in these cases.
<percentage>
Represents an edge offset as a percentage of the source image's size: the width of the image for horizontal offsets, the height for vertical offsets.
fill
Preserves the middle image region. Its width and height are sized to match the top and left image regions, respectively.

Description

The slicing process creates nine regions in total: four corners, four edges, and a middle region. Four slice lines, set a given distance from their respective sides, control the size of the regions.

The nine regions defined by the border-image or border-image-slice properties

The above diagram illustrates the location of each region.

The mask-border-repeat, mask-border-width, and mask-border-outset properties determine how these regions are used to form the final mask border.

Formal definition

Initial value0
Applies toall elements; In SVG, it applies to container elements excluding the defs element and all graphics elements
Inheritedno
Percentagesrefer to size of the mask border image
Computed valueas specified
Animation typediscrete

Formal syntax

<number-percentage>{1,4} fill?

where
<number-percentage> = <number> | <percentage>

Examples

Basic usage

This property doesn't appear to be supported anywhere yet. When it eventually starts to be supported, it will serve to define the size of the slices taken from the source image, and used to create the border mask.

mask-border-slice: 30 fill;

Chromium-based browsers support an outdated version of this property — mask-box-image-slice — with a prefix:

-webkit-mask-box-image-slice: 30 fill;

Note: The mask-border page features a working example (using the out-of-date prefixed border mask properties supported in Chromium), so you can get an idea of the effect.

Note: The fill keyword needs to be included if you want the element's content to be visible.

Specifications

SpecificationStatusComment
CSS Masking Module Level 1
The definition of 'mask-border-slice' in that specification.
Candidate RecommendationInitial definition

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:111 次

字数:9237

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文