The border-image-slice
CSS property divides the image specified by border-image-source
in nine regions: the four corners, the four edges and the middle.
/* border-image-slice: slice */ border-image-slice: 30%; /* border-image-slice: vertical horizontal */ border-image-slice: 10% 30%; /* border-image-slice: top horizontal bottom */ border-image-slice: 30 30% 45; /* border-image-slice: top right bottom left */ border-image-slice: 7 12 14 5; /* border-image-slice: … fill */ /* The fill value can be placed between any value */ border-image-slice: 10% fill 7 12; /* Global values */ border-image-slice: inherit; border-image-slice: initial; border-image-slice: unset;
It does this by specifying 4 inwards offsets.
Four values control the position of the slice lines. If some are not specified, they are inferred from the other with the usual 4-value syntax of CSS.
The middle is not used by the border itself but is used as a background-image if the keyword fill
is set. The keyword can be set at any position in the property (before, after or between the other values).
The border-image-repeat
, border-image-width
, border-image-outset
properties define how these images will be used.
The shorthand CSS property border-image
may reset this property to its default value.
Initial value | 100% |
---|---|
Applies to | all elements, except internal table elements when border-collapse is collapse . It also applies to ::first-letter . |
Inherited | no |
Percentages | refer to the size of the border image |
Media | visual |
Computed value | one to four percentage(s) (as specified) or absolute length(s), plus the keyword fill if specified |
Animation type | discrete |
Canonical order | the percentages or lengths, eventually followed by the keyword fill
|
This property may take one, two, three, or four values.
With one value:
With two values:
With three values:
With four values:
The fill value can be placed between any values.
<number>
or a <percentage>
of the offset for the four slicing lines. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.<number>
or a <percentage>
of the offset for the two slicing lines corresponding to the horizontal edges, the right and the left ones. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.<number>
or a <percentage>
of the offset for the two slicing lines corresponding to the vertical edges, the top and the bottom ones. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.<number>
or a <percentage>
of the offset for the top slicing line. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.<number>
or a <percentage>
of the offset for the bottom slicing line. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.<number>
or a <percentage>
of the offset for the right slicing line. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.<number>
or a <percentage>
of the offset for the left slicing line. The <number>
represents pixels for raster images and coordinates for vector images. Also, <percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%
.fill
inherit
<number-percentage>{1,4} && fill?where
<number-percentage> = <number> | <percentage>
Specification | Status | Comment |
---|---|---|
CSS Backgrounds and Borders Module Level 3 The definition of 'border-image-slice' in that specification. | Candidate Recommendation | Initial defintion |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 15 | Yes | 151 2 3 4 | 11 | 15 | 6 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 4.1 -webkit- | ? | Yes | 151 2 3 4 | No | ? | ? |
1. Small SVGs are incorrectly stretched, because percentages in border-image-slice
are computed to integers instead of floats (bug 1284797).
2. Until Firefox 47, SVGs without viewport were not sliced correctly (bug 619500).
3. From Firefox 48 until Firefox 49, SVGs without viewport are displayed the same as SVGs with viewport, but if the slices are not exactly 50%, they are incorrectly stretched (bug 1264809).
4. Until Firefox 57, an issue persisted for SVGs without viewport when e10s was disabled (bug 1290782).
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-slice