repeating-radial-gradient

  • Revision slug: CSS/repeating-radial-gradient
  • Revision title: repeating-radial-gradient
  • Revision id: 21543
  • Created:
  • Creator: nimbupani
  • Is current revision? No
  • Comment Reverted to earlier version; 14 words added, 6 words removed

Revision Content

{{ SeeCompatTable() }}

This works similarly to the standard radial gradients as described by {{ cssxref("radial-gradient") }}, but it automatically repeats the color stops infinitely in both directions, with their positions shifted by multiples of the difference between the last color stop's position and the first one's position.

Like any other gradient, a repeating CSS radial gradient is not a CSS <color> but an image with no intrinsic dimensions; that is, it has no natural or preferred size, nor ratio. Its concrete size will match the one of the element it applies to.

Note: Mozilla's syntax proposal for CSS gradients differs significantly from WebKit's proposal.
  • Gecko (Firefox) uses separate kinds of property values to distinguish radial and linear gradients, whereas WebKit lumps them into a single kind of property value and needs a leading parameter to identify the type of gradient.
  • The actual syntax for how a radial gradient is specified is significantly different.

Mozilla currently only supports CSS gradients as values of the {{ Cssxref("background-image") }} property, as well as within the shorthand {{ Cssxref("background") }}. You specify a gradient value instead of an image URL.

Syntax

-moz-repeating-radial-gradient( [<position> || <angle>,]? [<shape> || <size>,]? <stop>, <stop>[, <stop>]* )

Values

<position>
A position, interpreted in the same way as {{ Cssxref("background-position") }} or {{ Cssxref("-moz-transform-origin") }}. If omitted, the default is center.
<angle>
An angle establishing the gradient line, which extends from the starting point at this angle; this is 0deg by default.
<shape>
The gradient's shape. This is one of circle (meaning that the gradient's shape is a circle with constant radius) or ellipse (meaning that the shape is an axis-aligned ellipse). The default value is ellipse.
<size>
The size of the gradient. This is one of the {{ anch("Size constants") }} listed below.
<stop>
This value is comprised of a {{ Xref_csscolorvalue() }} value, followed by an optional stop position (either a percentage between 0% and 100% or a {{ Xref_csslength() }} along the gradient axis).
Rendering of color-stops in CSS gradients follows the same rules as color-stops in SVG gradients.

Size constants

Constant Description
closest-side
The gradient's shape meets the side of the box closest to its center (for circles) or meets both the vertical and horizontal sides closest to the center (for ellipses).
closest-corner The gradient's shape is sized so it exactly meets the closest corner of the box from its center.
farthest-side Similar to closest-side, except the shape is sized to meet the side of the box farthest from its center (or vertical and horizontal sides).
farthest-corner
The gradient's shape is sized so it exactly meets the farthest corner of the box from its center.
contain
A synonym for closest-side.
cover
A synonym for farthest-corner.

Usage

Radial gradients also run along an axis. At each end point of the axis, a radius is specified. This can be imagined as creating two "circles", where for each circle the center is specified by the point and the radius is specified by the radius length. The gradient runs outwards from the circumference of the inner circle to the circumference of the outer circle.

background: -moz-repeating-radial-gradient(black, black 5px, white 5px, white 10px);

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 10
-webkit-repeating-radial-gradient()
3.6 (1.9.2)
-moz-repeating-radial-gradient()
5.5 (including 8.0)
filter: progid:DXImageTransform.Microsoft.Gradient()

12

-o-repeating-radial-gradient()

5.1  -webkit-repeating-radial-gradient()
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

Revision Source

<p>{{ SeeCompatTable() }}</p>
<p>This works similarly to the standard radial gradients as described by {{ cssxref("radial-gradient") }}, but it automatically repeats the color stops infinitely in both directions, with their positions shifted by multiples of the difference between the last color stop's position and the first one's position.</p>
<p>Like any other gradient, a repeating CSS radial gradient is not a CSS <span class="lang lang-en"><code><a href="color_value" rel="custom">&lt;color&gt;</a></code> </span> but an image with <a href="/en/CSS/image#no_intrinsic" title="en/CSS/image#no_intrinsic">no intrinsic dimensions</a>; that is, it has no natural or preferred size, nor ratio. Its concrete size will match the one of the element it applies to.</p>
<div class="note"><strong>Note: </strong> Mozilla's syntax proposal for CSS gradients differs significantly from WebKit's proposal. <ul> <li>Gecko (Firefox) uses separate kinds of property values to distinguish radial and linear gradients, whereas WebKit lumps them into a single kind of property value and needs a leading parameter to identify the type of gradient.</li> <li>The actual syntax for how a radial gradient is specified is significantly different.</li> </ul>
</div>
<p>Mozilla currently only supports CSS gradients as values of the {{ Cssxref("background-image") }} property, as well as within the shorthand {{ Cssxref("background") }}. You specify a gradient value instead of an image URL.</p>
<h2>Syntax</h2>
<pre>-moz-repeating-radial-gradient( [&lt;position&gt; || &lt;angle&gt;,]? [&lt;shape&gt; || &lt;size&gt;,]? &lt;stop&gt;, &lt;stop&gt;[, &lt;stop&gt;]* )
</pre>
<h2>Values</h2>
<dl> <dt>&lt;position&gt;</dt> <dd>A position, interpreted in the same way as {{ Cssxref("background-position") }} or {{ Cssxref("-moz-transform-origin") }}. If omitted, the default is <code>center</code>.</dd> <dt>&lt;angle&gt;</dt> <dd>An angle establishing the gradient line, which extends from the starting point at this angle; this is <code>0deg</code> by default.</dd> <dt>&lt;shape&gt;</dt> <dd>The gradient's shape. This is one of <code>circle</code> (meaning that the gradient's shape is a circle with constant radius) or <code>ellipse</code> (meaning that the shape is an axis-aligned ellipse). The default value is <code>ellipse</code>.</dd> <dt>&lt;size&gt;</dt> <dd>The size of the gradient. This is one of the {{ anch("Size constants") }} listed below.</dd> <dt>&lt;stop&gt;</dt> <dd>This value is comprised of a {{ Xref_csscolorvalue() }} value, followed by an optional stop position (either a percentage between 0% and 100% or a {{ Xref_csslength() }} along the gradient axis).</dd> <dd>Rendering of color-stops in CSS gradients follows the same rules as color-stops in SVG gradients.</dd>
</dl>
<h2>Size constants</h2>
<table class="standard-table"> <tbody> <tr> <th>Constant</th> <th>Description</th> </tr> <tr> <td><code>closest-side<br> </code></td> <td>The gradient's shape meets the side of the box closest to its center (for circles) or meets both the vertical and horizontal sides closest to the center (for ellipses).</td> </tr> <tr> <td><code>closest-corner</code></td> <td>The gradient's shape is sized so it exactly meets the closest corner of the box from its center.</td> </tr> <tr> <td><code>farthest-side</code></td> <td>Similar to closest-side, except the shape is sized to meet the side of the box farthest from its center (or vertical and horizontal sides).</td> </tr> <tr> <td><code>farthest-corner<br> </code></td> <td>The gradient's shape is sized so it exactly meets the farthest corner of the box from its center.</td> </tr> <tr> <td><code>contain<br> </code></td> <td>A synonym for <code>closest-side</code>.</td> </tr> <tr> <td><code>cover<br> </code></td> <td>A synonym for <code>farthest-corner</code>.</td> </tr> </tbody>
</table>
<h2>Usage</h2>
<p>Radial gradients also run along an axis. At each end point of the axis, a radius is specified. This can be imagined as creating two "circles", where for each circle the center is specified by the point and the radius is specified by the radius length. The gradient runs outwards from the circumference of the inner circle to the circumference of the outer circle.</p>
<pre>background: -moz-repeating-radial-gradient(black, black 5px, white 5px, white 10px);</pre>
<h2>Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<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 (WebKit)</th> </tr> <tr> <td>Basic support</td> <td>10<br> <code>-webkit-repeating-radial-gradient()</code></td> <td>3.6 (1.9.2)<br> <code>-moz-repeating-radial-gradient()</code></td> <td>5.5 (including 8.0)<br> <code>filter: progid:DXImageTransform.Microsoft.Gradient()</code></td> <td> <p>12 <a class="external" href="http://my.opera.com/desktopteam/blog/2011/10/07/ragnarok-css3-radial-gradients" title="http://my.opera.com/desktopteam/blog/2011/10/07/ragnarok-css3-radial-gradients"></a></p> <p><a class="external" href="http://my.opera.com/desktopteam/blog/2011/10/07/ragnarok-css3-radial-gradients" title="http://my.opera.com/desktopteam/blog/2011/10/07/ragnarok-css3-radial-gradients"><code>-o-repeating-radial-gradient()</code></a></p> </td> <td>5.1  <code>-webkit-repeating-radial-gradient()</code></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>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<h2>See also</h2>
<ul> <li><a href="/en/CSS/Using_CSS_gradients" title="en/Using gradients">Using gradients</a></li> <li>{{ cssxref("repeating-linear-gradient") }}</li> <li>{{ cssxref("-moz-radial-gradient") }}</li> <li>{{ cssxref("background-image") }}</li> <li>{{ Cssxref("background") }}</li> <li>WebKit's original proposal: <a class="external" href="http://webkit.org/blog/175/introducing-css-gradients/" title="http://webkit.org/blog/175/introducing-css-gradients/">http://webkit.org/blog/175/introducing-css-gradients/</a></li> <li>Bug: {{ bug("479220") }}</li> <li>W3C Proposal for Radial Gradients: <a class="external" href="http://dev.w3.org/csswg/css3-images/#radial-gradients" title="http://dev.w3.org/csswg/css3-images/#radial-gradients">http://dev.w3.org/csswg/css3-images/#radial-gradients</a></li> <li>W3C Proposal for Background Position: <a class="external" href="http://www.w3.org/TR/css3-background/#the-background-position" title="http://www.w3.org/TR/css3-background/#the-background-position">http://www.w3.org/TR/css3-background/#the-background-position</a></li> <li><a class="external" href="http://msdn.microsoft.com/en-us/library/ms532997(VS.85,loband).aspx" title="http://msdn.microsoft.com/en-us/library/ms532997(VS.85,loband).aspx">MSDN library, gradient filter</a> (reference doc)</li> <li><a class="external" href="http://webkit.org/blog/1424/css3-gradients/">Safari: CSS3 Gradients</a> (blog post)</li>
</ul>
Revert to this revision