CSS
背景和边框 | Backgrounds & Borders

边框图像重复 | border-image-repeat

border-image-repeat

border-image-repeat定义图片如何填充边框。或为单个值,设置所有的边框;或为两个值,分别设置水平与垂直的边框。

/* border-image-repeat: type */ border-image-repeat: stretch; /* border-image-repeat: horizontal vertical */ border-image-repeat: round stretch; /* Global values */ border-image-repeat: inherit; border-image-repeat: initial; border-image-repeat: unset;

初始值stretch
适用元素all elements, except internal table elements when border-collapse is collapse. It also applies to ::first-letter.
是否是继承属性no
适用媒体visual
计算值as specified
Animation typediscrete
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

typestretch,repeat,round,space选一。属于单个值的情况。horizontalstretch,repeat,round,space选一。属于两个值的情况。verticalstretch,repeat,round,space选一。属于两个值的情况。stretch拉伸图片以填充边框。repeat平铺图片以填充边框。round平铺图像。当不能整数次平铺时,根据情况放大或缩小图像。space平铺图像 。当不能整数次平铺时,会用空白间隙填充在图像周围(不会放大或缩小图像)inherit继承父级元素的计算值。

正式语法

[ stretch | repeat | round | space ]{1,2}

示例

CSS内容

#borderImageRepetition { width: 260px; height: 80px; margin-bottom: 10px; border: 30px solid; border-image: url("https://mdn.mozillademos.org/files/4127/border.png") 27; border-image-repeat: stretch; /* Can be changed in the live sample */ }

规范

SpecificationStatusComment
CSS Backgrounds and Borders Module Level 3The definition of 'border-image-repeat' in that specification.Candidate RecommendationInitial definition

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support15.0(Yes)15.0 (15.0)11156
round303(Yes)15.0 (15.0)11?9.14
space561(Yes)50.0 (50.0)211No support9.14

FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support?(Yes)15.0 (15.0)No support?9.34
round?(Yes)15.0 (15.0)???
space?(Yes)50.0 (50.0)2???