<repeating-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> ]?
示例代码:
(图一)
repeating-linear-gradient(#f00, #ff0 10%, #f00 15%);
repeating-linear-gradient(to bottom, #f00, #ff0 10%, #f00 15%);
repeating-linear-gradient(180deg, #f00, #ff0 10%, #f00 15%);
repeating-linear-gradient(to top, #f00, #ff0 10%, #f00 15%);
以上几句代码都可以实现如(图一)的渐变效果
其实可以使用 linear-gradient() 做出 repeating-linear-gradient()
的效果
暴力实现上述(图一)的效果:
repeating-linear-linear-gradient(#f00, #ff0 10%, #f00 15%, #ff0 25%, #f00 30%, #ff0 40%, #f00 45%, #ff0 55%, #f00 60%, #ff0 70%, #f00 75%, #ff0 85%, #f00 90%, #ff0);
以上几句代码都可以实现如(图一)的渐变效果
利用 background-size 实现上述(图一)的效果:
background: linear-gradient(#f00, #ff0 67%, #f00);
background-size: 100% 15%;
使用 background-size 约束渐变图像的大小,然后通过 background-repeat 来纵向平铺
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 | 3.1-5 | 9-11 | 3.2-4.3 | 2.1-3 | 7 | 10-11 | 61 | 56 | 10+ | 11.4 | 4+ | 1.2 | 7.12 |
10+ | 3.6-15 -moz- | 10-25 -webkit- | 5.1-6 -webkit- | 11.1-11.5 -o- | 5.0-6.1 -webkit- | 4-4.3 -webkit- | 10 | 11.1-11.5 -o- | ||||||||
16+ | 26+ | 6.1+ | 11.6-12 -o- | 7.0+ | 4.4+ | 12 -o- | ||||||||||
12.1+ | 12.1+ |