この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
この記事を English (US) で読むこともできます。

Draft
This page is not complete.

The repeating-conic-gradient() CSS function creates an image consisting of a repeating gradient (rather than a single gradient) with color transitions rotated around a center point (rather than radiating from the center). Example repeating conic gradients include starbursts. The result of the repeating-conic-gradient() function is an object of the <gradient> data type, which is a special kind of <image>.

If neither the first nor the last color stops include include a a color stop angle greater than 0deg or less than 360 degrees respectively, the conic-gradient will not repeat.

As with any gradient, a repeating-conic gradient has no intrinsic dimensions; i.e., it has no natural or preferred size, nor a preferred ratio. Its concrete size will match the size of the element it applies to, or the size the <image> is set to if it's set to something other than the element's size.

Because <gradient>s belong to the <image> data type, they can only be used where <image>s can be used. For this reason, repeating-conic-gradient() won't work on background-color and other properties that use the <color> data type.

To create a conic gradient that doe not repeat, make the gradient a full 360 degree rotation, or use the conic-gradient() function instead.

Understanding repeating conic gradients

The repeating-conic-gradient syntax is similar to the  conic-gradient() and repeating-radial-gradient() syntax. Like the non-repeating conic-gradient, the color-stops are placed around a gradient arc. Like the repeating radial gradient, the size of the repeating section is the first color stop subtracted from the angle of the last color stop.

Comparison of the color stops for repeating and non-repeating conic and radial gradients

The above gradients are defined as being one third blue, one third red, and one third yellow.

repeating-conic-gradient(from 0deg, red 0deg 30deg, yellow 30deg 60deg, blue 60deg 90deg);

repeating-radial-gradient(red 0 8%, yellow 8% 16%, blue 16% 24%);

conic-gradient(red 120deg, yellow 120deg 240deg, blue 240deg);

radial-gradient(red 33%, yellow 33% 66%, blue 66%);

For a repeating gradient to repeat we define the first and last color stops. Like in non-repeating gradients, the first and last color stops are assumed to be 0 and either 100% or 360deg if not explicitly declared. When defaulting to these values, the repeating arc is 360 degrees, and therefore doesn't repeat.

Like the non-repeating conic gradient, the color-stops are placed around a gradient arc -- the circumference of a circle, rather than on the gradient line emerging from the center of the gradient. The colors transition as as if spun around the center of a circle, starting at the top if no from <angle> is declared, and going clockwise for the the size of the angle that is the different between the largest and smallest color angle, then repeating.

A repeating conic gradient is specified by indicating a rotation angle, the center of the gradient, and then specifying a list of color-stops. Like non-repeating conic gradients, the color-stops of a repeating conic gradient are specified with an <angle>. Units include deg for degrees, grad for gradients, rad for radians, and turn for turns. There are 360 degrees, 400 gradians, 2π radians, and 1 turn in a circle. Browsers supporting repeating conic gradients also accept percent values, with 100% equaling 360 degrees, but this is not in the specification.

Radial and conic gradient syntax provides for positioning the center of the gradient anywhere within, or even outside, the image. The values for the position are similar to the syntax for 2-value background-position.

The gradient arc is part of the circumference of the gradient. 0 degress is north, or 12:00pm. The colors of the gradient are determined by the angled color stops, their starting points, ending points, and, in between, and optional angled color-stop points. The transitions between colors can be altered with color hints between adjacent colors' color stops.

Customizing gradients

By adding more angled color-stop points on the gradient arc, you can create a highly customized transition between multiple colors. A color-stop's position can be explicitly defined by using an <angle>. If you don't specify the location of a color stop, it is placed halfway between the one that precedes it and the one that follows it. Like the non-repeating gradient counterpart, If you don't specify an angle for the first or last color stop, the values are will be 0deg and 360deg. If you don't declare an angle for either, you'll get a non-repeating conic gradient. If you declare a non 0 or 360degree for the first or last respectively, the gradient will repeat based on that value. For example, if you don't declare an angle for the first color, and declare 10% on the last color stop, the arc will repeat 10 times. Rather, the starting point is the first color stop declared, and the last color stop is the last color stop angle declared.. The following two gradients are equivalent

repeating-conic-gradient(red, orange, yellow, green, blue 50%);
repeating-conic-gradient(from -45deg, red 45deg, orange, yellow, green, blue 225deg)

By default, colors transition smoothly from the color at one color stop to the color at the subsequent color stop, with the midpoint between the colors being the half way point between the color transition. You can move this color transition midpoint to any point between two color stops by adding a color hint, indicating where the middle of the color transition should be.

If two or more color stops are at the same location, the transition will be a hard line between the first and last colors declared at that location.

While you can mix and match different angle units, don't. It makes CSS hard to read.

Syntax

/* Starburst: A a blue on blue starburst: the gradient 
   is a starburst of lighter and darker blue,
   centered in the upper left quandrant,
   offset by 3degrees so there is no up/down straight line */
background: repeating-conic-gradient(
    from 3deg at 25% 25%,
    hsl(200, 100%, 50%) 0deg 15deg,
    hsl(200, 100%, 60%) 10deg 30deg);
);

Values

<angle>
Preceded by the from keyterm, and taking an angle as its value, defines the gradient rotation in clockwise direction.
<position>
Using the same length, order and keyterm values as the background-position property, the position defines center of the gradient. If omitted, the default value is center, meaing the gradient will be centered, .
<angular-color-stop>
A color-stop's <color> value, followed by one or two optional stop positions, (an <angle> along the gradient's circumference axis). The last color stop minus the first color-stop angle defines the size of the repeating gradient.
<color-hint>
Th color-hint is an interpolation hint defining how the gradient progresses between adjacent color stops. The length defines at which point between two color stops the gradient color should reach the midpoint of the color transition. If omitted, the midpoint of the color transition is the midpoint between two color stops.

Note: Rendering of color stops in CSS gradients follows the same rules as color stops in SVG gradients.

Formal syntax

repeating-conic-gradient(
  [ from <angle> ]? [ at <position> ]?, <angular-color-stop-list> )
  \---------------------------------/ \----------------------------/
        Gradient definition                List of color stops

where <angular-color-stop-list> = [ <angular-color-stop> [, <angular-color-hint>]? ]# , <angular-color-stop>
  and <angular-color-stop> = <color> && <color-stop-angle>?
  and <angular-color-hint> = <angle-percentage>
  and <color-stop-angle> = <angle-percentage>{1,2}

Examples

Black and white starburst

div {
  background-image:
     repeating-conic-gradient(#fff 0 9deg, #000 9deg 18deg);
}

Off-centered gradient

div {
  background: repeating-conic-gradient(
    from 3deg at 25% 25%, 
    green, blue 2deg 5deg, green, yellow 15deg 18deg, green 20deg);
}

It repeats 18 times, but since we only see the right half, we only see 9 repeats.

Note: Please see Using CSS gradients for more examples.

Accessibility concerns

Browsers do not provide any special information on background images to assistive technology. This is important primarily for screen readers, as a screen reader will not announce its presence and therefore convey nothing to its users. While it is possible to create pie charts, checkerboards, and other effects with conic gradients, CSS images provide no native way to assign alternative text, and therefore the image represented by the conic gradient will not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document.

Specifications

Specification Status Comment
CSS Images Module Level 4
The definition of 'repeating-conic-gradient()' in that specification.
Working Draft

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
conic-gradient()Chrome Full support 69
Full support 69
Full support 59
Disabled
Disabled From version 59: this feature is behind the Enable Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support NoIE No support NoOpera Full support 56Safari Full support 12.1WebView Android Full support 69
Full support 69
Full support 59
Disabled
Disabled From version 59: this feature is behind the Enable Experimental Web Platform Features preference.
Chrome Android Full support 69
Full support 69
Full support 59
Disabled
Disabled From version 59: this feature is behind the Enable Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support NoOpera Android Full support 48Safari iOS Full support 12.2Samsung Internet Android No support No
Double-position color stopsChrome Full support 72Edge No support NoFirefox No support NoIE No support NoOpera No support NoSafari Full support 12.1WebView Android Full support 72Chrome Android Full support 72Firefox Android No support NoOpera Android No support NoSafari iOS Full support 12.2Samsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

ドキュメントのタグと貢献者

このページの貢献者: SphinxKnight, estelle
最終更新者: SphinxKnight,