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.

  • When one value is specified, it applies the same behavior on all four sides .
  • When two values are specified, the first applies to the top and bottom , the second to the left and right .

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}
					

范例

Repeating border images

CSS

#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 */
}
					

HTML

<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>
					

JavaScript

var repetition = document.getElementById("repetition");
repetition.addEventListener("change", function (evt) {
  document.getElementById("bordered").style.borderImageRepeat = evt.target.value;
});
					

Results

规范

规范 状态 注释
CSS Backgrounds and Borders Module Level 3
The definition of 'border-image-repeat' in that specification.
候选推荐 初始定义

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

元数据

  • 最后修改: