linear-gradient

< css‎ | functions(Redirected from css/linear-gradient)
Jump to: navigation, search

linear-gradient

This article is Ready to Use.


W3C Candidate Recommendation

Summary

Defines a linear gradient as a CSS image.

Examples

View live example

CSS

background: #1e5799;
background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(100%,#7db9e8));
background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%);
background: linear-gradient(to bottom, #1e5799 0%,#7db9e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 );


Syntax

linear-gradient ([ [ <angle> | to <side-or-corner> ] , ] ? <color-stop> [ , <color-stop> ] +)

Parameters

angle
Optional. The angle the gradient line should assume, expressed as a number followed by an angle units designator(for instance, "deg")."0deg" points upward and positive angles increase in a clockwise direction. Therefore, "90deg" points toward the right, "180deg" points downward, and so on.If no angle is provided, the gradient line starts in the corner or side opposite the corner or side specified by <side-or-corner>.
side-or-corner
Optional value that specifies an ending corner or side for the gradient. This value begins with "to", which is followed by one or two of the following keywords. Including one keyword specifies an ending side, and two keywords specify an ending corner.
  • The following values can be used as the first value only:
    • left Indicates gradient ends on the left.
    • right Indicates gradient ends on the right.
  • The following values can be used as the second value only:
    • top Indicates gradient ends on the top.
    • bottom Indicates gradient ends on the bottom.
  • Not including any keywords or angle is equivalent to "to bottom".
color-stop
At least two color stops are required. Each color stop has one or two components—a color component and an optional position component. The first component defines the color component of a stop point for the gradient. Each stop point has its own designated color, and the area between each point is filled with a continuous color transition from one to the other. This value can be any supported color value.Each stop point can have an optional percentage or supported length value that indicates where along the gradient line to place the color stop. "0%" (or "0px", "0em", and so on) indicates the starting point (or side); "100%" indicates the ending point (or side).

Related specifications

Specification Status Related Changes
CSS Image Values and Replaced Content Module Level 3 Candidate Recommendation Section 4.1

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic Support
22 -webkit
16
3.6 -moz
10
10 -ms
12.1
12 -o
5.1 -webkit

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic support ? ? ? ? ? ? ? ?


Compatibility notes

Browser Version Note
Internet Explorer 6 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000');
Internet Explorer 10 Supports the previous syntax ("top" instead of "to bottom") as the vendor prefixed version (-ms-linear-gradient), supports the latest syntax ("to bottom" instead of "top") as the non prefixed version (linear-gradient.
Chrome 22 and later Only supports the previous syntax ("top" instead of "to bottom") as the vendor prefixed version (-webkit-linear-gradient) and the obsolete syntax as a vendor prefixed version (-webkit-gradient).
Safari 5.1 and later Only supports the previous syntax ("top" instead of "to bottom") as the vendor prefixed version (-webkit-linear-gradient) and the obsolete syntax as a vendor prefixed version (-webkit-gradient).

See also

Related articles

Gradients


  • linear-gradient







Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]