Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS radial-gradient() Function

CSS radial-gradient() Function

CSS Functions CSS Functions

Example

The following example demonstrates a radial gradient - with evenly distributed color stops:

#grad

{

background-image:

radial-gradient

(

red

,

green

,

blue

)

;

}

Try it »


Definition and usage

The radial-gradient() function creates an "image" with a radial gradient.

A radial gradient is defined by a center point.

To create a radial gradient you must set two color stops.

Radial gradient example

Supported version: CSS3


Browser support

The numbers in the table indicate the first browser version that supports the function.

The number prefixed by "webkit", "moz", or "o" indicates the first version that supports the function.

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 Syntax



background-image: radial-gradient(shape size at position, start-color, ..., last-color);

Value Description
shape Determine the type of circle:
  • ellipse (default): specifies an elliptical radial gradient.
  • circle: specifies a circular radial gradient
  • | | *size* | Defines the size of the gradient, possible values: | | *position* | Defines the position of the gradient. Possible values: | | *start-color, ..., last-color* | Used to specify the start and end colors of the gradient. |

    More examples

    Example

    Unevenly distributed color stops:

    #grad

    {

    background-image:

    radial-gradient

    (

    red

    5

    %

    ,

    green

    15

    %

    ,

    blue

    60

    %

    )

    ;

    }

    Try it »

    Example

    Circular radial gradient:

    #grad

    {

    background-image:

    radial-gradient

    (

    circle

    ,

    red

    ,

    yellow

    ,

    green

    )

    ;

    }

    Try it »

    Example

    Using different size keywords:

    #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

    )

    ;

    }

    Try it »

    CSS Tutorial: CSS3 Gradients

    CSS Functions CSS Functions