radial-gradient() function - HTML CSS CSS

HTML CSS examples for CSS:Function

Definition and Usage

The radial-gradient() function creates a gradient of colors radiating from the center of the gradient.

To create a radial gradient you must also define at least two color stops.

CSS Syntax

ValueDescription Value
shapeshape of the gradient. Possible values: ellipse (default)/ circle
size size of the gradient. Possible values: farthest-corner (default) closest-side closest-corner farthest-side
position Defines the position of the gradient. Default is "center"
start-color, ..., last-color Color stops to render. A color value, followed by an optional stop position (a percentage between 0% and 100% or a length along the gradient axis).

A radial gradient with evenly spaced color stops:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#grad1 {<!--from  ww w .j  a v  a 2  s  .co  m-->
    height: 150px;
    width: 200px;
    background: -webkit-radial-gradient(red 5%, green 15%, yellow 60%); /* Safari 5.1 to 6.0 */
    background: -o-radial-gradient(red 5%, green 15%, yellow 60%); /* For Opera 11.6 to 12.0 */
    background: -moz-radial-gradient(red 5%, green 15%, yellow 60%); /* For Firefox 3.6 to 15 */
    background: radial-gradient(red 5%, green 15%, yellow 60%); /* Standard syntax (must be last) */
}
</style>
</head>
<body>

<div id="grad1"></div>

</body>
</html>

Related Tutorials