<linear-gradient> = linear-gradient([ [ <angle> | to <side-or-corner> ] ,]? <color-stop>[, <color-stop>]+)
<side-or-corner> = [left | right] || [top | bottom]
<color-stop> = <color> [ <length> | <percentage> ]?
to top left
这样的多关键字方式来实现。用默认的渐变方向绘制一个最简单的线性渐变
示例代码:
(图一)
linear-gradient(#fff, #333);
linear-gradient(to bottom, #fff, #333);
linear-gradient(to top, #333, #fff);
linear-gradient(180deg, #fff, #333);
linear-gradient(to bottom, #fff 0%, #333 100%);
以上几句代码都可以实现如(图一)的渐变效果
IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
---|---|---|---|---|---|---|---|
6.0-9.0 #2 | 2.0-3.5 | 4.0-9.0 -webkit- #1 |
3.1-3.2 | 15.0+ | 3.2-4.3 -webkit- #1 |
2.1-3.0 -webkit- #1 |
10.0-25.0 -webkit- #1 |
10.0+ | 3.6-15.0 -moz- |
10.0-25.0 -webkit- |
4.0-5.0 -webkit- #1 |
5.0-6.1 | 4.0-4.3 -webkit- |
26.0+ | |
16.0+ | 26.0+ | 5.1-6.0 -webkit- |
7.0+ | 4.4+ | |||
6.1+ |