CSS conic-gradient()関数
例
3色の円錐曲線:
#grad {
background-image: conic-gradient(red, yellow,
green);
}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
conic-gradient()関数は、背景画像として円錐曲線を設定します。
円錐曲線は、中心点を中心に回転する色の変化を伴うグラデーションです。
円錐曲線を作成するには、少なくとも2つのカラーストップを定義する必要があります。
円錐曲線の例:
バージョン: | CSS3 |
---|
ブラウザのサポート
表の数字は、この機能を完全にサポートする最初のブラウザバージョンを示しています。
Function | |||||
---|---|---|---|---|---|
conic-gradient() | 69.0 | 79.0 | 83.0 | 12.1 | 56.0 |
CSS構文
background-image: conic-gradient([from angle] [at position,] color degree, color degree, ...);
Value | Description |
---|---|
from angle | Optional. The entire conic gradient is rotated by this angle. Default value is 0deg |
at position | Optional. Specifies the gradient center of the conic gradient. Default value is center |
color degree, ..., color degree | Color stops are the colors you want to render smooth transitions among. This value consists of a color value, followed by an optional stop position (a degree between 0 and 360 or a percent between 0% and 100%). |
その他の例
例
5色の円錐曲線:
#grad {
background-image: conic-gradient(red, yellow, green, blue,
black);
}
例
3色と各色の次数を持つ円錐曲線:
#grad {
background-image: conic-gradient(red 45deg, yellow 90deg, green 210deg)
}
例
border-radius:50%を追加して、円錐曲線のグラデーションをパイのように見せます。
#grad {
background-image: conic-gradient(red, yellow, green, blue,
black);
border-radius: 50%;
}
例
from角度の円錐曲線:
#grad {
background-image: conic-gradient(from 90deg, red, yellow, green);
border-radius: 50%;
}
例
at位置の円錐曲線:
#grad {
background-image: conic-gradient(at 60% 45%, red, yellow, green);
border-radius: 50%;
}
例
角度からと位置の両方での円錐曲線:
#grad {
background-image: conic-gradient(from 90deg at 60% 45%, red, yellow, green);
border-radius: 50%;
}
例
別の円グラフ:
#grad {
background-image: conic-gradient(red 0deg, red 90deg, yellow
90deg, yellow 180deg, green 180deg);
border-radius: 50%;
}
関連ページ
CSSチュートリアル:CSSグラデーション