border-image-repeat
CSS
property defines how the
edge regions
of a source image are adjusted to fit the dimensions of an element's
border image
.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
/* Keyword value */ border-image-repeat: stretch; border-image-repeat: repeat; border-image-repeat: round; border-image-repeat: space; /* vertical | horizontal */ border-image-repeat: round stretch; /* Global values */ border-image-repeat: inherit; border-image-repeat: initial; border-image-repeat: unset;
border-image-repeat
property may be specified using one or two values chosen from the list of values below.
stretch
The source image's edge regions are stretched to fill the gap between each border.
repeat
The source image's edge regions are tiled (repeated) to fill the gap between each border. Tiles may be clipped to achieve the proper fit.
round
The source image's edge regions are tiled (repeated) to fill the gap between each border. Tiles may be stretched to achieve the proper fit.
space
The source image's edge regions are tiled (repeated) to fill the gap between each border. Extra space will be distributed in between tiles to achieve the proper fit.
| 初始值 |
stretch
|
|---|---|
| 适用于 |
all elements, except internal table elements when
border-collapse
is
collapse
. It also applies to
::first-letter
.
|
| 继承 | no |
| 计算值 | 如指定 |
| 动画类型 | discrete |
[ stretch | repeat | round | space ]{1,2}
#bordered {
width: 12rem;
margin-bottom: 1rem;
padding: 1rem;
border: 40px solid;
border-image: url("https://mdn.mozillademos.org/files/4127/border.png") 27;
border-image-repeat: stretch; /* Can be changed in the live sample */
}
<div id="bordered">You can try out various border repetition rules on me!</div> <select id="repetition"> <option value="stretch">stretch</option> <option value="repeat">repeat</option> <option value="round">round</option> <option value="space">space</option> <option value="stretch repeat">stretch repeat</option> <option value="space round">space round</option> </select>
var repetition = document.getElementById("repetition");
repetition.addEventListener("change", function (evt) {
document.getElementById("bordered").style.borderImageRepeat = evt.target.value;
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Backgrounds and Borders Module Level 3
The definition of 'border-image-repeat' in that specification. |
候选推荐 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
border-image-repeat
|
Chrome 完整支持 15 | Edge 完整支持 12 | Firefox 完整支持 15 | IE 完整支持 11 | Opera 完整支持 15 | Safari 完整支持 6 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 15 | Opera Android 完整支持 14 | Safari iOS 完整支持 9.3 | Samsung Internet Android 完整支持 1.0 |
round
|
Chrome 完整支持 30 | Edge 完整支持 12 | Firefox 完整支持 15 | IE 完整支持 11 | Opera 完整支持 17 | Safari 完整支持 9.1 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 30 | Firefox Android 完整支持 15 | Opera Android 完整支持 18 | Safari iOS 完整支持 9.3 | Samsung Internet Android 完整支持 2.0 |
space
|
Chrome 完整支持 56 | Edge 完整支持 12 | Firefox 完整支持 50 | IE 完整支持 11 | Opera 完整支持 43 | Safari 完整支持 9.1 | WebView Android 完整支持 56 | Chrome Android 完整支持 56 | Firefox Android 完整支持 50 | Opera Android 完整支持 43 | Safari iOS 完整支持 9.3 | Samsung Internet Android 完整支持 6.0 |
完整支持
background
background-attachment
background-clip
background-color
background-image
background-origin
background-position
background-position-x
background-position-y
background-repeat
background-size
border
border-bottom
border-bottom-color
border-bottom-left-radius
border-bottom-right-radius
border-bottom-style
border-bottom-width
border-color
border-image
border-image-outset
border-image-repeat
border-image-slice
border-image-source
border-image-width
border-left
border-left-color
border-left-style
border-left-width
border-radius
border-right
border-right-color
border-right-style
border-right-width
border-style
border-top
border-top-color
border-top-left-radius
border-top-right-radius
border-top-style
border-top-width
border-width
box-shadow