Sunday, October 20, 2013

Radial Gradient using css3

The CSS radial-gradient() function creates an <image> which represents a gradient of colors radiating from an origin, the centerof the gradient. The result of this function is an object of the CSS <gradient> data type.
Radial gradients are defined by their center, the ending shape contour and position, and color stops. The radial gradient consists, going from its center to its ending shape and potentially beyond, of successive uniformly-scaled concentric shapes, identical to the ending shape. Color stops are positioned on a virtual gradient ray going out horizontally of the center and going to the right. Percentages positioning of color stops are relative to the intersection between the ending shape and this gradient ray representing 100%. Each shape is monocolor and defined by the color on the gradient ray it intersects.
Ending shapes can only be circle or ellipse.
Like any other gradient, a CSS radial gradient is not a CSS <color> but an image with no intrinsic dimensions, i. e. it has no natural or preferred size, nor ratio. Its concrete size will match the one of the element it applies to.
The radial-gradient function does not allow repeating gradients. For such a functionality, use the CSS repeating-radial-gradient function.

Syntax

Formal grammar: 
  radial-gradient( [[ circle               || <length> ]                     [ at <position> ]? , | 
                    [ ellipse              || [<length> | <percentage> ]{2}] [ at <position> ]? , |
                    [ [ circle | ellipse ] || <extent-keyword> ]             [ at <position> ]? , |
                                                                               at <position> ,     <color-stop> [ , <color-stop> ]+ )
                   \------------------------------------------------------------------------------/\--------------------------------/
                                 Definition of the contour, size and position of the ending shape         List of color stops  
    
          where <extent-keyword> = closest-corner | closest-side | farthest-corner | farthest-side
            and <color-stop> = <color> [ <percentage> | <length> ]?
Definition of the ending shape
radial-gradient( circle, … )                /* Synonym of radial-gradient( circle farthest-corner, …) */
radial-gradient( ellipse, … )               /* Synonym of radial-gradient( ellipse farthest-corner, …) */
radial-gradient( <extent-keyword>, … )      /* It draws a circle */
radial-gradient( circle radius, … )         /* A centered circle of the given length. It can't be a percentage */
radial-gradient( ellipse x-axis y-axis, … ) /* The two semi-major axis are given, horizontal, then vertical */

Definition of the position of the shape
radial-gradient (… at <position>, … )

Definition of the color stops
radial-gradient (…, <color-stop>)
radial-gradient (…, <color-stop>, <color-stop>)

Values

<position>
<position>, interpreted in the same way as background-position or transform-origin. If omitted, the default is center.
<shape>
The gradient's shape. This is one of circle (meaning that the gradient's shape is a circle with constant radius) or ellipse (meaning that the shape is an axis-aligned ellipse). The default value is ellipse.
<size>
The size of the gradient. This is one of the Size constants listed below.
<color-stop>
Representing a fixed color at a precise position, this value is composed by a <color> value, followed by an optional stop position (either a <percentage> or a<length> along the virtual gradient ray). A percentage of 0%, or a length of 0, represents the center of the gradient, the value 100% the intersection of the ending shape with the virtual gradient ray. Percentage values in-between. are linearily positioned on the gradient ray.
<extent-keyword>
Keywords describing how big the ending shape must be. The possible keywords are:

0 comments:

Post a Comment