border-image-width
CSS
property sets the width 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.
If this property's value is greater than the element's
border-width
, the border image will extend beyond the padding (and/or content) edge.
/* Keyword value */ border-image-width: auto; /* <length> value */ border-image-width: 1rem; /* <percentage> value */ border-image-width: 25%; /* <number> value */ border-image-width: 3; /* vertical | horizontal */ border-image-width: 2em 3em; /* top | horizontal | bottom */ border-image-width: 5% 15% 10%; /* top | right | bottom | left */ border-image-width: 5% 2em 10% auto; /* Global values */ border-image-width: inherit; border-image-width: initial; border-image-width: unset;
border-image-width
property may be specified using one, two, three, or four values chosen from the list of values below.
<length-percentage>
<length>
或
<percentage>
. Percentages are relative to the
width
of the border image area for horizontal offsets and the
height
of the border image area for vertical offsets. Must not be negative.
<number>
border-width
. Must not be negative.
auto
border-image-slice
. If the image does not have the required intrinsic dimension, the corresponding
border-width
is used instead.
| 初始值 |
1
|
|---|---|
| 适用于 |
all elements, except internal table elements when
border-collapse
is
collapse
. It also applies to
::first-letter
.
|
| 继承 | no |
| 百分比 | refer to the width or height of the border image area |
| 计算值 | as specified, but with relative lengths converted into absolute lengths |
| 动画类型 | by computed value type |
[ <length-percentage> | <number> | auto ]{1,4}where
<length-percentage> = <length> | <percentage>
This example creates a border image using the following ".png" file, which is 90 by 90 pixels:
Thus, each circle in the source image is 30 by 30 pixels.
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
p {
border: 20px solid;
border-image: url("https://mdn.mozillademos.org/files/10470/border.png") 30 round;
border-image-width: 16px;
padding: 40px;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Backgrounds and Borders Module Level 3
The definition of 'border-image-width' in that specification. |
候选推荐 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
border-image-width
|
Chrome 完整支持 15 | Edge 完整支持 12 | Firefox 完整支持 13 | IE 完整支持 11 | Opera 完整支持 15 | Safari 完整支持 6 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 14 | Opera Android 完整支持 14 | Safari iOS 完整支持 6 | Samsung Internet Android 完整支持 1.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