CSSのradial-gradient()関数
例
等間隔のカラーストップを使用した放射状グラデーション:
#grad {
background-image: radial-gradient(red, green, blue);
}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
radius-gradient()関数は、背景画像として放射状グラデーションを設定します。
放射状のグラデーションは、その中心によって定義されます。
放射状のグラデーションを作成するには、少なくとも2つのカラーストップを定義する必要があります。
ラジアルグラデーションの例:
バージョン: | CSS3 |
---|
ブラウザのサポート
表の数字は、この機能を完全にサポートする最初のブラウザバージョンを示しています。
数字の後に-webkit-、-moz-、または-o-が続く場合は、プレフィックスを使用して機能した最初のバージョンを指定します。
Function | |||||
---|---|---|---|---|---|
radial-gradient() | 26.0 10.0 -webkit- |
10.0 | 16.0 3.6 -moz- |
6.1 5.1 -webkit- |
12.1 11.6 -o- |
CSS構文
background-image: radial-gradient(shape size at position, start-color, ..., last-color);
Value | Description |
---|---|
shape | Defines the shape of the gradient. Possible values:
|
size | Defines the size of the gradient. Possible values:
|
position | Defines the position of the gradient. Default is "center" |
start-color, ..., last-color | 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 percentage between 0% and 100% or a length along the gradient axis). |
その他の例
例
異なる間隔のカラーストップを持つ放射状グラデーション:
#grad {
background-image: radial-gradient(red 5%, green 15%, blue 60%);
}
例
円の形をした放射状のグラデーション:
#grad {
background-image: radial-gradient(circle, red, yellow, green);
}
例
さまざまなサイズのキーワードを使用した放射状グラデーション:
#grad1 {
background-image: radial-gradient(closest-side at 60% 55%, blue, green, yellow, black);
}
#grad2 {
background-image: radial-gradient(farthest-side at 60% 55%, blue, green, yellow, black);
}
関連ページ
CSSチュートリアル:CSSグラデーション