CSS Gradients Browser compatibility
background: #74e3ec; /* Old Browsers */ background: -webkit-linear-gradient(top,#74e3ec,#c7ffe2); /*Safari 5.1-6*/ background: -o-linear-gradient(top,#74e3ec,#c7ffe2); /*Opera 11.1-12*/ background: -moz-linear-gradient(top,#74e3ec,#c7ffe2); /*Fx 3.6-15*/ background: linear-gradient(to bottom, #74e3ec, #c7ffe2); /*Standard*/
CSS3 gradients let you display smooth transitions between two or more specified colors.
Earlier, you had to use images for these effects. However, by using CSS3 gradients you can reduce download time and bandwidth usage. In addition, elements with gradients look better when zoomed, because the gradient is generated by the browser.
CSS3 defines two types of gradients:
- Linear Gradients (goes down/up/left/right/diagonally)
- Radial Gradients (defined by their center)
The <gradient> CSS data type denotes a CSS <image> made of a progressive transition between two or more colors. A CSS gradient is not a CSS <color> but an image with no intrinsic dimensions; that is, it has no natural or preferred size, nor a preferred ratio. Its concrete size will match the one of the element it applies to.
There are three kinds of color gradients:
- linear gradients, generated by the linear-gradient() function, where the color smoothly fades along an imaginary line.
- radial gradients, generated by the radial-gradient() function. The more away from an origin a point is, the more far from the original color it is.
- repeating gradients, which are fixed sized linear or radial gradients repeated as much as needed to fill the entire box.
A linear gradient is created by specifying a straight gradient line, and then several colors placed along that line. The image is constructed by creating an infinite canvas and painting it with lines perpendicular to the gradient line, with the color of the painted line being the color of the gradient line where the two intersect. This produces a smooth fade from each color to the next, progressing in the specified direction.Definition from W3C
In a radial gradient, rather than colors smoothly fading from one side of the gradient box to the other as with linear gradients, they instead emerge from a single point and smoothly spread outward in a circular or elliptical shape.
A radial gradient is specified by indicating the center of the gradient (where the 0% ellipse will be) and the size and shape of the ending shape (the 100% ellipse). Color stops are given as a list, just as for linear-gradient(). Starting from the gradient center and progressing towards (and potentially beyond) the ending shape uniformly-scaled concentric ellipses are drawn and colored according to the specified color stops.