Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1046650 of border-image-slice

  • Revision slug: Web/CSS/border-image-slice
  • Revision title: border-image-slice
  • Revision id: 1046650
  • Created:
  • Creator: Simplexible
  • Is current revision? No
  • Comment {{xref_csspercentage}} replaced with {{cssxref("<percentage>")}}

Revision Content

{{CSSRef}}

Summary

The border-image-slice CSS property divides the image specified by {{cssxref("border-image-source")}} in nine regions: the four corners, the four edges and the middle. It does this by specifying 4 inwards offsets.

The nine slices defined by the CSS border-image shorthand or border-image-slice longhand propertiesFour values control the position of the slice lines. If some are not specified, they are inferred from the other with the usual 4-value syntax of CSS.

The middle is not used by the border itself but is used as a background-image if the keyword fill is set. The keyword can be set at any position in the property (before, after or between the other values).

The {{cssxref("border-image-repeat")}}, {{cssxref("border-image-width")}}, {{cssxref("border-image-outset")}} properties define how these images will be used.

The shorthand CSS property {{cssxref("border-image")}} may reset this property to its default value.

{{cssinfo}}

Syntax

/* border-image-slice: slice */
border-image-slice: 30%; 

/* border-image-slice: horizontal vertical */
border-image-slice: 10% 30%;

/* border-image-slice: top horizontal bottom */
border-image-slice: 30 30% 45;

/* border-image-slice: top right bottom left */
border-image-slice: 7 12 14 5; 

/* border-image-slice: … fill */
/* The fill value can be placed between any value */
border-image-slice: 10% fill 7 12;

/* Global values */
border-image-slice: inherit;
border-image-slice: initial;
border-image-slice: unset;

Values

slice
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the four slicing lines. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
horizontal
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the two horizontal slicing lines, the top and the bottom ones. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
vertical
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the two vertical slicing lines, the right and the left ones. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
top
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the top slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
bottom
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the bottom slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
right
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the right slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
left
Is a {{xref_cssnumber}} or a {{cssxref("<percentage>")}} of the offset for the left slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents pixels for raster images and coordinates for vector images. Also, {{cssxref("<percentage>")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to 100%.
fill
Is a keyword whose presence forces the use of the middle image slice to be displayed over the background image, its size and height are resized like those of the top and left image slices, respectively.
inherit
Is a keyword indicating that all four values are inherited from their parent's element calculated value.

Formal syntax

{{csssyntax}}

Specifications

Specification Status Comment
{{SpecName('CSS3 Backgrounds', '#border-image-slice', 'border-image-slice')}} {{Spec2('CSS3 Backgrounds')}} Initial defintion

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 15.0 {{CompatGeckoDesktop("15.0")}} 11 15 6
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 4.1{{property_prefix("-webkit")}} {{CompatGeckoMobile("15.0")}} {{CompatNo}} {{CompatUnknown}} {{CompatUnknown}}

Revision Source

<div>{{CSSRef}}</div>

<h2 id="Summary">Summary</h2>

<p>The <strong><code>border-image-slice</code></strong> CSS property divides the image specified by {{cssxref("border-image-source")}} in nine regions: the four corners, the four edges and the middle. It does this by specifying 4 inwards offsets.</p>

<p><a href="/files/3814/border-image-slice.png" style="float: left; "><img alt="The nine slices defined by the CSS border-image shorthand or border-image-slice longhand properties" src="/files/3814/border-image-slice.png" style="height:132px; margin:1px; padding:1em; width:250px" /></a>Four values control the position of the slice lines. If some are not specified, they are inferred from the other with the usual 4-value syntax of CSS.</p>

<p>The middle is not used by the border itself but is used as a background-image if the keyword <code>fill</code> is set. The keyword can be set at any position in the property (before, after or between the other values).</p>

<p>The {{cssxref("border-image-repeat")}}, {{cssxref("border-image-width")}}, {{cssxref("border-image-outset")}} properties define how these images will be used.</p>

<p>The shorthand CSS property {{cssxref("border-image")}} may reset this property to its default value.</p>

<p>{{cssinfo}}</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush:css">
/* border-image-slice: <em>slice</em> */
border-image-slice: 30%; 

/* border-image-slice: <em>horizontal</em> <em>vertical</em> */
border-image-slice: 10% 30%;

/* border-image-slice: <em>top</em> <em>horizontal</em> <em>bottom</em> */
border-image-slice: 30 30% 45;

/* border-image-slice: <em>top</em> <em>right</em> <em>bottom</em> <em>left</em> */
border-image-slice: 7 12 14 5; 

/* border-image-slice: … fill */
/* The fill value can be placed between any value */
border-image-slice: 10% fill 7 12;

/* Global values */
border-image-slice: inherit;
border-image-slice: initial;
border-image-slice: unset;
</pre>

<h3 id="Values">Values</h3>

<dl>
 <dt><em>slice</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the four slicing lines. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><em>horizontal</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the two horizontal slicing lines, the top and the bottom ones. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><em>vertical</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the two vertical slicing lines, the right and the left ones. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><em>top</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the top slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><em>bottom</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the bottom slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><em>right</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the right slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><em>left</em></dt>
 <dd>Is a {{xref_cssnumber}} or a {{cssxref("&lt;percentage&gt;")}} of the offset for the left slicing line. Note that a {{cssxref("")}} value is not allowed, and therefore invalid. The {{xref_cssnumber}} represents <em>pixels</em> for raster images and <em>coordinates</em> for vector images. Also, {{cssxref("&lt;percentage&gt;")}} values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to <code>100%</code>.</dd>
 <dt><code>fill</code></dt>
 <dd>Is a keyword whose presence forces the use of the middle image slice to be displayed over the background image, its size and height are resized like those of the top and left image slices, respectively.</dd>
 <dt><code>inherit</code></dt>
 <dd>Is a keyword indicating that all four values are inherited from their parent's element calculated value.</dd>
</dl>

<h3 id="Formal_syntax">Formal syntax</h3>

<pre class="syntaxbox">
{{csssyntax}}</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Backgrounds', '#border-image-slice', 'border-image-slice')}}</td>
   <td>{{Spec2('CSS3 Backgrounds')}}</td>
   <td>Initial defintion</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>15.0</td>
   <td>{{CompatGeckoDesktop("15.0")}}</td>
   <td>11</td>
   <td>15</td>
   <td>6</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>4.1{{property_prefix("-webkit")}}</td>
   <td>{{CompatGeckoMobile("15.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>
Revert to this revision