linear-gradient() background color gradient

css syntax

background: linear-gradient(direction,color-stop1,color-stop2,...);
direction:用角度值指定渐变的方向(或角度);
color-stop1,color-stop2,...:用于指定渐变的起止颜色
ps:至少需要两种颜色
1   background: -webkit-linear-gradient(red,yellow,blue); /* Safari 5.1-6.0 */
2   background: -o-linear-gradient(red,yellow,blue); /* Opera 11.1-12.0 */ 
3   background: -moz-linear-gradient(red,yellow,blue); /* Firefox 3.6-15 */
4   background: linear-gradient(red,yellow,blue); /* 标准语法 */

compatibilityInsert picture description here

Instance

1. background: linear-gradient(to left,#d3959b,#bfe6ba);
to left set the gradient from right to left, equivalent to 270deg! [
](https://img-blog.csdnimg.cn/20191206160101202.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dhbmd5YW54aW45Mjg=,size_16,color_FFFFFF,t_70)
2. background: linear-gradient(to right,#d3959b,#bfe6ba);
to right set the gradient from left to right, equivalent to 90deg
Insert picture description here
3. background: linear-gradient(to top,#d3959b,#bfe6ba);
to top set the gradient from bottom to top, equivalent to 0deg
Insert picture description here
4. background: linear-gradient( to bottom,#d3959b,#bfe6ba);
Insert picture description here
5. background: linear-gradient(to top right,#d3959b,#bfe6ba);
to right top = to top right: from the lower left corner to the upper right corner, the diagonal angle
Insert picture description here
6. background: linear-gradient(45deg,#d3959b,#bfe6ba);
is slightly different from to top right (there is no difference when the background is square)
Insert picture description here
7. background: linear-gradient(45deg,#d3959b 20%,#bfe6ba);
Specify the starting color position as a percentage, the default value is 0%;
Insert picture description here
8. background: linear-gradient(to right,#feac5e,#c779d0,#4bc0c8);
Insert picture description here
9. background: linear-gradient(45deg,#feac5e,#c779d0,#4bc0c8);
Insert picture description here
10. background: linear-gradient(45deg,rgba(254,172,94,0.5),rgba(199,121,208,0.5),rgba(75,192,200, 0.5));
rgba uses 0.5 transparency
Insert picture description here

Guess you like

Origin blog.csdn.net/wangyanxin928/article/details/103425002