<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 | Edge | Firefox | Chrome | Safari | Opera | iOS Safari |
Android Browser |
Blackberry Browser |
Opera Mobile |
Chrome for Android |
Firefox for Android |
IE Mobile |
UC Browser for Android |
Samsung Internet |
QQ Browser |
Baidu Browser |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5.5-9 | 12+ | 2-3.5 | 4-9 -webkit- | 3.1-3.2 | 9-11 | 3.2-4.3 -webkit- | 2.1-3 -webkit- | 7 -webkit- | 10-11 | 61 | 56 | 10+ | 11.4 | 4+ | 1.2 | 7.12 |
10+ | 3.6-15 -moz- | 10-25 -webkit- | 4-5 -webkit- | 11.1-11.5 -o- #1 | 5.0-6.1 -webkit- | 4-4.3 -webkit- | 10 | 11.1-11.5 -o- #1 | ||||||||
16+ | 26+ | 5.1-6 -webkit- | 11.6-12 -o- | 7.0+ | 4.4+ | 12 -o- | ||||||||||
6.1+ | 12.1+ | 12.1+ |