{"id":19812,"date":"2013-01-09T15:13:10","date_gmt":"2013-01-09T22:13:10","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=19812"},"modified":"2022-12-05T13:28:20","modified_gmt":"2022-12-05T21:28:20","slug":"border-image","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/b\/border-image\/","title":{"rendered":"border-image"},"content":{"rendered":"\n
The The only required property for the This property specifies the source for the border image. This can be a URL, data URI, CSS gradient, or inline SVG (though support is limited for inline SVG, see SVG usage notes<\/a>).<\/p>\n\n\n\n The initial value is The values of this property tell the browser where to \u201cslice\u201d the image to create the pieces of the border. The image is divided into 9 sections \u2014 the four corners, the four sides, and the center.<\/p>\n\n\n\n The property accepts up to four positive unitless numbers or percentages, and an optional Unitless numbers measure the slice by pixels on a raster image, and by coordinates on an SVG. A percentage value is relative to the size of the image. For example, on a raster image that is 100px x 100px, The values measure from the top, right, bottom, and left edges of the image (in that order). If one value is missing, its value defaults to the value of its opposite side \u2014 for example if the left value is missing, but the right value is set at 10px, the left value becomes 10px too.<\/p>\n\n\n\n By default, the center of the source image is discarded. But, when the This property sets the width of the border image. It accepts a percentage value, a positive unitless number, or the keyword The values are for the top, right, bottom, and left sides of the element (in that order). If one value is missing, it is drawn the same as its opposite value.<\/p>\n\n\n\n For this property, percentage values are relative to the size of the border image area, while a unitless number is multiplied with the The initial value is The border-image<\/code> is a shorthand property that lets you use an image or CSS gradient as the border of an element.<\/p>\n\n\n\n
border-image<\/code> property can be applied to any element, except internal table elements (e.g. tr, th, td) when
border-collapse<\/code> is set to
collapse<\/code>.<\/p>\n\n\n\n\n\n\n\n
.element {\n border-image: url(border.png) 25 25 round;\n}<\/code><\/pre>\n\n\n
Syntax<\/h3>\n\n\n
border-image: <'border-image-source'> || <'border-image-slice'> [ \/ <'border-image-width'> | \/ <'border-image-width'>? \/ <'border-image-outset'> ]? || <'border-image-repeat'><\/code><\/pre>\n\n\n
Properties<\/h3>\n\n\n
border-image<\/code> shorthand is
border-image-source<\/code>. The other properties default to their initial values if they’re not specified. These are the
border-image<\/code> properties in order:<\/p>\n\n\n
border-image-source<\/code><\/h4>\n\n\n
.element {\n border-image-source: url(border.png);\n}<\/code><\/pre>\n\n\n\n
none<\/code>.<\/p>\n\n\n
border-image-slice<\/code><\/h4>\n\n\n
.element {\n border-image-source: url(border.png);\n border-image-slice: 20;\n}<\/code><\/pre>\n\n\n\n
fill<\/code> keyword. The initial value is
100%<\/code>.<\/p>\n\n\n\n
10%<\/code> from any side of the image is 10px. See the usage notes on SVG<\/a> for more information about how percentages work on SVG images.<\/p>\n\n\n\n
fill<\/code> keyword is used, it’s applied to the background of the bordered element instead.<\/p>\n\n\n
border-image-width<\/code><\/h4>\n\n\n
.element {\n border-image-source: url(border.png);\n border-image-slice: 20;\n border-image-width: 20;\n}<\/code><\/pre>\n\n\n\n
auto<\/code>.<\/p>\n\n\n\n
border-width<\/code>.<\/p>\n\n\n\n
1<\/code>, so if this value is not set but there’s a
border<\/code> or
border-width<\/code> declaration for the element, the border image will be drawn at that width.<\/p>\n\n\n\n
auto<\/code> keyword tells the browser to use either the size of the
border-image-slice<\/code> if available, or the size of the
border-width<\/code>.<\/p>\n\n\n
border-image-outset<\/code><\/h4>\n\n\n
.element {\n border-image-source: url(border.png);\n border-image-slice: 20;\n border-image-width: 20;\n border-image-outset: 1;\n}<\/code><\/pre>\n\n\n\n