Revision 487251 of -moz-image-region

  • Revision slug: Web/CSS/-moz-image-region
  • Revision title: -moz-image-region
  • Revision id: 487251
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Editorial review

Revision Content

{{ CSSMozExtensionRef() }}

Summary

For certain XUL elements and pseudo-elements that use an image from the {{ Cssxref("list-style-image") }} property, this property specifies a region of the image that is used in place of the whole image. This allows elements to use different pieces of the same image to improve performance.

The syntax is similar to the {{ Cssxref("clip") }} property. All four values are relative to the upper left corner of the image.

  • {{ Xref_cssinitial() }} {{ Cssxref("auto") }}
  • Applies to XUL {{ XULElem("image") }} elements and {{ Cssxref(":-moz-tree-image") }}, {{ Cssxref(":-moz-tree-twisty") }}, and {{ Cssxref(":-moz-tree-checkbox") }} pseudo-elements. Note: -moz-image-region only works with {{ XULElem("image") }} elements where the icon is specified using list-style-image. It will not work with XUL image src="url".
  • {{ Xref_cssinherited() }} yes
  • Percentages n/a
  • Media {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }} For rect() values, a rect consisting of four computed lengths; otherwise as specified.

Syntax

-moz-image-region: rect(top, right, bottom, left);

Examples

#example-button {
  /* display only the 4x4 area from the top left of this image */
  list-style-image: url("chrome://example/skin/example.png");
  -moz-image-region: rect(0px, 4px, 4px, 0px);
}
#example-button:hover {
  /* use the 4x4 area to the right of the first for the hovered button */
  -moz-image-region: rect(0px, 8px, 4px, 4px);
}

Revision Source

<div>
 {{ CSSMozExtensionRef() }}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>For certain XUL elements and pseudo-elements that use an image from the {{ Cssxref("list-style-image") }} property, this property specifies a region of the image that is used in place of the whole image. This allows elements to use different pieces of the same image to improve performance.</p>
<p>The syntax is similar to the {{ Cssxref("clip") }} property. All four values are relative to the upper left corner of the image.</p>
<ul class="cssprop">
 <li><dfn>{{ Xref_cssinitial() }}</dfn> {{ Cssxref("auto") }}</li>
 <li><dfn>Applies to</dfn> XUL {{ XULElem("image") }} elements and {{ Cssxref(":-moz-tree-image") }}, {{ Cssxref(":-moz-tree-twisty") }}, and {{ Cssxref(":-moz-tree-checkbox") }} pseudo-elements. <strong>Note:</strong> -moz-image-region only works with {{ XULElem("image") }} elements where the icon is specified using list-style-image. It will not work with XUL image src="url".</li>
 <li><dfn>{{ Xref_cssinherited() }}</dfn> yes</li>
 <li><dfn>Percentages</dfn> n/a</li>
 <li><dfn>Media</dfn> {{ Xref_cssvisual() }}</li>
 <li><dfn>{{ Xref_csscomputed() }}</dfn> For <code>rect()</code> values, a rect consisting of four computed lengths; otherwise as specified.</li>
</ul>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
-moz-image-region: rect(<em>top</em>, <em>right</em>, <em>bottom</em>, <em>left</em>);</pre>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush:css">
#example-button {
  /* display only the 4x4 area from the top left of this image */
  list-style-image: url("chrome://example/skin/example.png");
  -moz-image-region: rect(0px, 4px, 4px, 0px);
}
#example-button:hover {
  /* use the 4x4 area to the right of the first for the hovered button */
  -moz-image-region: rect(0px, 8px, 4px, 4px);
}</pre>
Revert to this revision